ZQuest Classic Coverage Report


Directory: src/
File: src/zc/guys.cpp
Date: 2024-09-12 17:48:44
Exec Total Coverage
Lines: 9101 12019 75.7%
Functions: 354 407 87.0%
Branches: 7250 12790 56.7%

Line Branch Exec Source
1 #include <cstring>
2 #include <stdio.h>
3 #include "base/zc_alleg.h"
4 #include "zc/guys.h"
5 #include "zc/replay.h"
6 #include "zc/zc_ffc.h"
7 #include "zc/zelda.h"
8 #include "base/zsys.h"
9 #include "base/msgstr.h"
10 #include "zc/maps.h"
11 #include "zc/hero.h"
12 #include "subscr.h"
13 #include "zc/ffscript.h"
14 #include "gamedata.h"
15 #include "defdata.h"
16 #include "zscriptversion.h"
17 #include "particles.h"
18 #include "base/zc_math.h"
19 #include "slopes.h"
20 #include "base/qrs.h"
21 #include "base/dmap.h"
22 #include "base/mapscr.h"
23 #include "base/misctypes.h"
24 #include "base/initdata.h"
25 #include "zc/combos.h"
26 extern particle_list particles;
27
28 extern ZModule zcm;
29 extern HeroClass Hero;
30 extern sprite_list guys, items, Ewpns, Lwpns, chainlinks, decorations;
31
32 int32_t repaircharge=0;
33 bool adjustmagic=false;
34 bool learnslash=false;
35 int32_t wallm_load_clk=0;
36 int32_t sle_x,sle_y,sle_cnt,sle_clk=0;
37 int32_t vhead=0;
38 int32_t guycarryingitem=0;
39
40 char *guy_string[eMAXGUYS];
41
42 void never_return(int32_t index);
43 void playLevelMusic();
44
45 // If an enemy is this far out of the playing field, just remove it.
46 #define OUTOFBOUNDS ((int32_t)y>((isSideViewGravity() && canfall(id))?192:352) || y<-176 || x<-256 || x > 512)
47 //#define NEWOUTOFBOUNDS ((int32_t)y>32767 || y<-32767 || x<-32767 || x > 32767)
48 #define IGNORE_SIDEVIEW_PLATFORMS (editorflags & ENEMY_FLAG14)
49 #define OFFGRID_ENEMY (editorflags & ENEMY_FLAG15)
50
51 1111857 void do_fix(zfix& coord, int32_t val, bool nearest_half = false)
52 {
53 1111857 int32_t c = coord.getInt();
54
2/2
✓ Branch 0 taken 267 times.
✓ Branch 1 taken 1111590 times.
1111857 if(nearest_half)
55 {
56
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1111590 times.
1111590 if (c < 0)
57 c -= val / 2;
58 1111590 else c += (val/2);
59 1111590 }
60 1111857 c -= c % val;
61 1111857 coord = c;
62 1111857 }
63
64 bool NEWOUTOFBOUNDS(zfix x, zfix y, zfix z)
65 {
66 return
67 (
68 (((int32_t)y) > FFCore.enemy_removal_point[spriteremovalY2])
69 || (((int32_t)y) < FFCore.enemy_removal_point[spriteremovalY1])
70 || (((int32_t)x) < FFCore.enemy_removal_point[spriteremovalX1])
71 || (((int32_t)x) > FFCore.enemy_removal_point[spriteremovalX2])
72 || (((int32_t)z) < FFCore.enemy_removal_point[spriteremovalZ1])
73 || (((int32_t)z) > FFCore.enemy_removal_point[spriteremovalZ2])
74 );
75 }
76
77 namespace
78 {
79 int32_t trapConstantHorizontalID;
80 int32_t trapConstantVerticalID;
81 int32_t trapLOSHorizontalID;
82 int32_t trapLOSVerticalID;
83 int32_t trapLOS4WayID;
84
85 int32_t cornerTrapID;
86 int32_t centerTrapID;
87
88 int32_t rockID;
89 int32_t zoraID;
90 int32_t statueID;
91 }
92
93 339 void identifyCFEnemies()
94 {
95 339 trapConstantHorizontalID=-1;
96 339 trapConstantVerticalID=-1;
97 339 trapLOSHorizontalID=-1;
98 339 trapLOSVerticalID=-1;
99 339 trapLOS4WayID=-1;
100 339 cornerTrapID=-1;
101 339 centerTrapID=-1;
102 339 rockID=-1;
103 339 zoraID=-1;
104 339 statueID=-1;
105
106
2/2
✓ Branch 0 taken 173568 times.
✓ Branch 1 taken 339 times.
173907 for(int32_t i=0; i<eMAXGUYS; i++)
107 {
108
3/4
✓ Branch 0 taken 334 times.
✓ Branch 1 taken 173234 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 334 times.
173568 if((guysbuf[i].flags&guy_trph) && trapLOSHorizontalID==-1)
109 334 trapLOSHorizontalID=i;
110
4/4
✓ Branch 0 taken 345 times.
✓ Branch 1 taken 173223 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 339 times.
173568 if((guysbuf[i].flags&guy_trpv) && trapLOSVerticalID==-1)
111 339 trapLOSVerticalID=i;
112
3/4
✓ Branch 0 taken 339 times.
✓ Branch 1 taken 173229 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 339 times.
173568 if((guysbuf[i].flags&guy_trp4) && trapLOS4WayID==-1)
113 339 trapLOS4WayID=i;
114
3/4
✓ Branch 0 taken 339 times.
✓ Branch 1 taken 173229 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 339 times.
173568 if((guysbuf[i].flags&guy_trplr) && trapConstantHorizontalID==-1)
115 339 trapConstantHorizontalID=i;
116
3/4
✓ Branch 0 taken 339 times.
✓ Branch 1 taken 173229 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 339 times.
173568 if((guysbuf[i].flags&guy_trpud) && trapConstantVerticalID==-1)
117 339 trapConstantVerticalID=i;
118
119
3/4
✓ Branch 0 taken 339 times.
✓ Branch 1 taken 173229 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 339 times.
173568 if((guysbuf[i].flags&guy_trap) && cornerTrapID==-1)
120 339 cornerTrapID=i;
121
3/4
✓ Branch 0 taken 339 times.
✓ Branch 1 taken 173229 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 339 times.
173568 if((guysbuf[i].flags&guy_trp2) && centerTrapID==-1)
122 339 centerTrapID=i;
123
124
3/4
✓ Branch 0 taken 339 times.
✓ Branch 1 taken 173229 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 339 times.
173568 if((guysbuf[i].flags&guy_rock) && rockID==-1)
125 339 rockID=i;
126
4/4
✓ Branch 0 taken 358 times.
✓ Branch 1 taken 173210 times.
✓ Branch 2 taken 21 times.
✓ Branch 3 taken 337 times.
173568 if((guysbuf[i].flags&guy_zora) && zoraID==-1)
127 337 zoraID=i;
128
129
4/4
✓ Branch 0 taken 398 times.
✓ Branch 1 taken 173170 times.
✓ Branch 2 taken 59 times.
✓ Branch 3 taken 339 times.
173568 if((guysbuf[i].flags & guy_fire) && statueID==-1)
130 339 statueID=i;
131 173568 }
132 339 }
133
134 32 int32_t random_layer_enemy()
135 {
136 32 int32_t cnt=count_layer_enemies();
137
138
1/2
✓ Branch 0 taken 32 times.
✗ Branch 1 not taken.
32 if(cnt==0)
139 {
140 return eNONE;
141 }
142
143 32 int32_t ret=zc_oldrand()%cnt;
144 32 cnt=0;
145
146
1/2
✓ Branch 0 taken 32 times.
✗ Branch 1 not taken.
32 for(int32_t i=0; i<6; ++i)
147 {
148
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 32 times.
32 if(tmpscr->layermap[i]!=0)
149 {
150 32 mapscr *layerscreen=&TheMaps[(tmpscr->layermap[i]-1)*MAPSCRS]+tmpscr->layerscreen[i];
151
152
1/2
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
140 for(int32_t j=0; j<10; ++j)
153 {
154
2/4
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 140 times.
140 if(layerscreen->enemy[j]>0&&layerscreen->enemy[j]<MAXGUYS)
155 {
156
2/2
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 108 times.
140 if(cnt==ret)
157 {
158 32 return layerscreen->enemy[j];
159 }
160
161 108 ++cnt;
162 108 }
163 108 }
164 }
165 }
166
167 return eNONE;
168 32 }
169
170 49 int32_t count_layer_enemies()
171 {
172 49 int32_t cnt=0;
173
174
2/2
✓ Branch 0 taken 294 times.
✓ Branch 1 taken 49 times.
343 for(int32_t i=0; i<6; ++i)
175 {
176
2/2
✓ Branch 0 taken 215 times.
✓ Branch 1 taken 79 times.
294 if(tmpscr->layermap[i]!=0)
177 {
178 79 mapscr *layerscreen=&TheMaps[(tmpscr->layermap[i]-1)*MAPSCRS]+tmpscr->layerscreen[i];
179
180
2/2
✓ Branch 0 taken 790 times.
✓ Branch 1 taken 79 times.
869 for(int32_t j=0; j<10; ++j)
181 {
182
2/2
✓ Branch 0 taken 370 times.
✓ Branch 1 taken 420 times.
790 if(layerscreen->enemy[j]!=0)
183 {
184 420 ++cnt;
185 420 }
186 790 }
187 79 }
188 294 }
189
190 49 return cnt;
191 }
192
193 211789 int32_t hero_on_wall()
194 {
195 211789 zfix lx = Hero.getX();
196 211789 zfix ly = Hero.getY();
197
198
199
200
4/4
✓ Branch 0 taken 189837 times.
✓ Branch 1 taken 21952 times.
✓ Branch 2 taken 8850 times.
✓ Branch 3 taken 180987 times.
211789 if(lx>=48 && lx<=192)
201 {
202
2/2
✓ Branch 0 taken 231 times.
✓ Branch 1 taken 180756 times.
180987 if(ly==32) return up+1;
203
204
2/2
✓ Branch 0 taken 283 times.
✓ Branch 1 taken 180473 times.
180756 if(ly==128) return down+1;
205 180473 }
206
207
4/4
✓ Branch 0 taken 194033 times.
✓ Branch 1 taken 17242 times.
✓ Branch 2 taken 21403 times.
✓ Branch 3 taken 172630 times.
211275 if(ly>=48 && ly<=112)
208 {
209
2/2
✓ Branch 0 taken 223 times.
✓ Branch 1 taken 172407 times.
172630 if(lx==32) return left+1;
210
211
2/2
✓ Branch 0 taken 172303 times.
✓ Branch 1 taken 104 times.
172407 if(lx==208) return right+1;
212 172303 }
213
214 210948 return 0;
215 211789 }
216
217 765531 bool tooclose(int32_t x,int32_t y,int32_t d)
218 {
219
2/2
✓ Branch 0 taken 567822 times.
✓ Branch 1 taken 197709 times.
765531 return (abs(int32_t(HeroX())-x)<d && abs(int32_t(HeroY())-y)<d);
220 }
221
222 3989892 bool enemy::overpit(enemy *e)
223 {
224 // This function (and shadow_overpit) has been broken since it was written, and only
225 // checked the same diagonal of the hitbox, over and over again. The bug is because both
226 // loops used the same variable name.
227 // Checking literally every pixel seems like overkill, so for now let's continue to
228 // do the single diagonal but just once. That's why the outer loop is commented out.
229
230 // for ( int32_t q = 0; q < hxsz; ++q )
231 {
232
2/2
✓ Branch 0 taken 36952798 times.
✓ Branch 1 taken 3970690 times.
40923488 for ( int32_t q = 0; q < hit_height; ++q )
233 {
234 //check every pixel of the hitbox
235
2/2
✓ Branch 0 taken 19202 times.
✓ Branch 1 taken 36933596 times.
36952798 if ( ispitfall(x+q+hxofs, y+q+hyofs) )
236 {
237 //if the hitbox is over a pit, we can't land
238 19202 return true;
239 }
240 36933596 }
241 }
242 3970690 return false;
243 3989892 }
244
245 12248388 bool enemy::shadow_overpit(enemy *e)
246 {
247 // for ( int32_t q = 0; q < hxsz; ++q )
248 {
249
2/2
✓ Branch 0 taken 176016029 times.
✓ Branch 1 taken 12221927 times.
188237956 for ( int32_t q = 0; q < hit_height; ++q )
250 {
251 //check every pixel of the hitbox
252
2/2
✓ Branch 0 taken 26461 times.
✓ Branch 1 taken 175989568 times.
176016029 if ( ispitfall(x+q+hxofs, y+q+hyofs+hit_height-2) )
253 {
254 //if the hitbox is over a pit, we can't land
255 26461 return true;
256 }
257 175989568 }
258 }
259 12221927 return false;
260 12248388 }
261
262 // Returns true iff a combo type or flag precludes enemy movement.
263 7430015 bool enemy::groundblocked(int32_t dx, int32_t dy, bool isKB)
264 {
265
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7430015 times.
7430015 if(moveflags & move_ignore_blockflags) return false;
266 7430015 int32_t c = COMBOTYPE(dx,dy);
267
4/4
✓ Branch 0 taken 4889751 times.
✓ Branch 1 taken 2540264 times.
✓ Branch 2 taken 1398275 times.
✓ Branch 3 taken 1141989 times.
9970279 bool pit_blocks = (!(moveflags & (move_can_pitwalk|move_only_pitwalk)) && (!(moveflags & move_can_pitfall) || !isKB));
268
3/6
✓ Branch 0 taken 2521940 times.
✓ Branch 1 taken 4908075 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2521940 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
7430015 bool water_blocks = (!(moveflags & (move_can_waterwalk|move_only_waterwalk|move_only_shallow_waterwalk)) && (!(moveflags & move_can_waterdrown) || !isKB) && get_qr(qr_DROWN));
269
5/6
✓ Branch 0 taken 2581486 times.
✓ Branch 1 taken 4848529 times.
✓ Branch 2 taken 2579609 times.
✓ Branch 3 taken 1877 times.
✓ Branch 4 taken 2579609 times.
✗ Branch 5 not taken.
14860794 return c==cPIT || c==cPITB || c==cPITC ||
270
4/6
✓ Branch 0 taken 2579609 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2579609 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2430861 times.
✓ Branch 5 taken 148748 times.
2579609 c==cPITD || c==cPITR || (pit_blocks && ispitfall(dx,dy)) ||
271 // Block enemies type and block enemies flags
272
2/2
✓ Branch 0 taken 2574333 times.
✓ Branch 1 taken 2425585 times.
148748 combo_class_buf[c].block_enemies&1 ||
273
4/4
✓ Branch 0 taken 2571663 times.
✓ Branch 1 taken 2670 times.
✓ Branch 2 taken 2571416 times.
✓ Branch 3 taken 247 times.
2574333 MAPFLAG(dx,dy)==mfNOENEMY || MAPCOMBOFLAG(dx,dy)==mfNOENEMY ||
274
4/4
✓ Branch 0 taken 2570598 times.
✓ Branch 1 taken 818 times.
✓ Branch 2 taken 2570532 times.
✓ Branch 3 taken 66 times.
2571416 MAPFLAG(dx,dy)==mfNOGROUNDENEMY || MAPCOMBOFLAG(dx,dy)==mfNOGROUNDENEMY ||
275 // Check for ladder-only combos which aren't dried water
276
4/4
✓ Branch 0 taken 10626 times.
✓ Branch 1 taken 2559906 times.
✓ Branch 2 taken 10331 times.
✓ Branch 3 taken 295 times.
5140769 (combo_class_buf[c].ladder_pass&1 && !iswater_type(c)) ||
277 // Check for drownable water
278
4/4
✓ Branch 0 taken 571946 times.
✓ Branch 1 taken 1998291 times.
✓ Branch 2 taken 1900 times.
✓ Branch 3 taken 570046 times.
2570237 (water_blocks && !(isSideViewGravity()) && (iswaterex(MAPCOMBO(dx,dy), currmap, currscr, -1, dx, dy, false, false, true, false, false)));
279 2584127 }
280
281 // Returns true iff enemy is floating and blocked by a combo type or flag.
282 8647446 bool enemy::flyerblocked(int32_t dx, int32_t dy, int32_t special, bool isKB)
283 {
284
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8647446 times.
8647446 if(moveflags & move_ignore_blockflags) return false;
285
4/4
✓ Branch 0 taken 6549648 times.
✓ Branch 1 taken 2097798 times.
✓ Branch 2 taken 1749398 times.
✓ Branch 3 taken 348400 times.
10745244 bool pit_blocks = (!(moveflags & move_can_pitwalk) && (!(moveflags & move_can_pitfall) || !isKB));
286
3/4
✓ Branch 0 taken 6564155 times.
✓ Branch 1 taken 2083291 times.
✓ Branch 2 taken 2083291 times.
✗ Branch 3 not taken.
10730737 bool water_blocks = (!(moveflags & move_can_waterwalk) && (!(moveflags & move_can_waterdrown) || !isKB));
287
2/2
✓ Branch 0 taken 1200827 times.
✓ Branch 1 taken 7446619 times.
16094065 return ((special==spw_floater)&&
288
2/2
✓ Branch 0 taken 7436494 times.
✓ Branch 1 taken 10125 times.
7446619 ((COMBOTYPE(dx,dy)==cNOFLYZONE)||
289
2/2
✓ Branch 0 taken 7436375 times.
✓ Branch 1 taken 119 times.
7436494 (combo_class_buf[COMBOTYPE(dx,dy)].block_enemies&4)||
290
2/2
✓ Branch 0 taken 7436204 times.
✓ Branch 1 taken 171 times.
7436375 (MAPFLAG(dx,dy)==mfNOENEMY)||
291
2/2
✓ Branch 0 taken 7435949 times.
✓ Branch 1 taken 255 times.
7436204 (MAPCOMBOFLAG(dx,dy)==mfNOENEMY)||
292
4/4
✓ Branch 0 taken 1242529 times.
✓ Branch 1 taken 6193420 times.
✓ Branch 2 taken 4004 times.
✓ Branch 3 taken 1238525 times.
14867894 (water_blocks && iswaterex(MAPCOMBO(dx, dy), currmap, currscr, -1, dx,dy, false, false, true)) ||
293
2/2
✓ Branch 0 taken 6183831 times.
✓ Branch 1 taken 1248114 times.
7431945 (pit_blocks && ispitfall(dx,dy))));
294 8647446 }
295 // Returns true iff a combo type or flag precludes enemy movement.
296 268956 bool groundblocked(int32_t dx, int32_t dy, guydata const& gd)
297 {
298 268956 int32_t c = COMBOTYPE(dx,dy);
299 268956 bool pit_blocks = !(gd.moveflags & move_can_pitwalk);
300
2/2
✓ Branch 0 taken 33457 times.
✓ Branch 1 taken 235499 times.
268956 bool water_blocks = !(gd.moveflags & move_can_waterwalk) && get_qr(qr_DROWN);
301
5/6
✓ Branch 0 taken 268936 times.
✓ Branch 1 taken 20 times.
✓ Branch 2 taken 268819 times.
✓ Branch 3 taken 117 times.
✓ Branch 4 taken 268819 times.
✗ Branch 5 not taken.
1014715 return c==cPIT || c==cPITB || c==cPITC ||
302
4/6
✓ Branch 0 taken 268819 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 268819 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 239043 times.
✓ Branch 5 taken 29776 times.
268819 c==cPITD || c==cPITR || (pit_blocks && ispitfall(dx,dy)) ||
303 // Block enemies type and block enemies flags
304
2/2
✓ Branch 0 taken 268246 times.
✓ Branch 1 taken 238470 times.
29776 combo_class_buf[c].block_enemies&1 ||
305
4/4
✓ Branch 0 taken 267920 times.
✓ Branch 1 taken 326 times.
✓ Branch 2 taken 267889 times.
✓ Branch 3 taken 31 times.
268246 MAPFLAG(dx,dy)==mfNOENEMY || MAPCOMBOFLAG(dx,dy)==mfNOENEMY ||
306
4/4
✓ Branch 0 taken 264389 times.
✓ Branch 1 taken 3500 times.
✓ Branch 2 taken 264114 times.
✓ Branch 3 taken 275 times.
267889 MAPFLAG(dx,dy)==mfNOGROUNDENEMY || MAPCOMBOFLAG(dx,dy)==mfNOGROUNDENEMY ||
307 // Check for ladder-only combos which aren't dried water
308
4/4
✓ Branch 0 taken 1042 times.
✓ Branch 1 taken 263072 times.
✓ Branch 2 taken 1003 times.
✓ Branch 3 taken 39 times.
528189 (combo_class_buf[c].ladder_pass&1 && !iswater_type(c)) ||
309 // Check for drownable water
310
4/4
✓ Branch 0 taken 42397 times.
✓ Branch 1 taken 221678 times.
✓ Branch 2 taken 24004 times.
✓ Branch 3 taken 18393 times.
264075 (water_blocks && !(isSideViewGravity()) && (iswaterex(MAPCOMBO(dx,dy), currmap, currscr, -1, dx, dy, false, false, true)));
311 }
312
313 // Returns true iff enemy is floating and blocked by a combo type or flag.
314 122271 bool flyerblocked(int32_t dx, int32_t dy, int32_t special, guydata const& gd)
315 {
316
2/2
✓ Branch 0 taken 119948 times.
✓ Branch 1 taken 2323 times.
122271 bool pit_blocks = (!(gd.moveflags & move_can_pitwalk) && !(gd.moveflags & move_can_pitfall));
317 122271 bool water_blocks = !(gd.moveflags & move_can_waterwalk);
318
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 122271 times.
244542 return ((special==spw_floater)&&
319
2/2
✓ Branch 0 taken 122174 times.
✓ Branch 1 taken 97 times.
122271 ((COMBOTYPE(dx,dy)==cNOFLYZONE)||
320
2/2
✓ Branch 0 taken 122169 times.
✓ Branch 1 taken 5 times.
122174 (combo_class_buf[COMBOTYPE(dx,dy)].block_enemies&4)||
321
2/2
✓ Branch 0 taken 122160 times.
✓ Branch 1 taken 9 times.
122169 (MAPFLAG(dx,dy)==mfNOENEMY)||
322
2/2
✓ Branch 0 taken 122131 times.
✓ Branch 1 taken 29 times.
122160 (MAPCOMBOFLAG(dx,dy)==mfNOENEMY)||
323
4/4
✓ Branch 0 taken 2321 times.
✓ Branch 1 taken 119810 times.
✓ Branch 2 taken 250 times.
✓ Branch 3 taken 2071 times.
244012 (water_blocks && iswaterex(MAPCOMBO(dx,dy), currmap, currscr, -1, dx, dy, false, false, true)) ||
324
2/2
✓ Branch 0 taken 119810 times.
✓ Branch 1 taken 2071 times.
121881 (pit_blocks && ispitfall(dx,dy))));
325 }
326
327
5/10
✓ Branch 0 taken 114515 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 114515 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 114515 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 114515 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 114515 times.
✗ Branch 9 not taken.
229030 enemy::enemy(zfix X,zfix Y,int32_t Id,int32_t Clk) : sprite()
328 114515 {
329
1/2
✓ Branch 0 taken 114515 times.
✗ Branch 1 not taken.
114515 x=X;
330
1/2
✓ Branch 0 taken 114515 times.
✗ Branch 1 not taken.
114515 y=Y;
331 114515 id=Id;
332 114515 clk=Clk;
333
1/2
✓ Branch 0 taken 114515 times.
✗ Branch 1 not taken.
114515 floor_y=y;
334 114515 ceiling=false;
335 114515 fading = misc = clk2 = clk3 = stunclk = hclk = sclk = superman = 0;
336 114515 grumble = movestatus = posframe = timer = ox = oy = 0;
337
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 114515 times.
✓ Branch 2 taken 114515 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 114515 times.
✗ Branch 5 not taken.
114515 yofs = (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) - ((isSideViewGravity()) ? 0 : 2);
338 114515 did_armos=true;
339 114515 script_spawned=false;
340
341 114515 d = guysbuf + (id & 0xFFF);
342 114515 hp = d->hp;
343 114515 starting_hp = hp;
344 // cs = d->cset;
345 //d variables
346
347 114515 flags=d->flags;
348 114515 flags=d->flags;
349 114515 s_tile=d->s_tile; //secondary (additional) tile(s)
350 114515 family=d->family;
351 114515 dcset=d->cset;
352 114515 cs=dcset;
353
2/2
✓ Branch 0 taken 88395 times.
✓ Branch 1 taken 26120 times.
114515 anim=get_qr(qr_NEWENEMYTILES)?d->e_anim:d->anim;
354 114515 dp=d->dp;
355 114515 wdp=d->wdp;
356 114515 wpn=d->weapon;
357 114515 wpnsprite = d-> wpnsprite; //2.6 -Z
358 114515 rate=d->rate;
359 114515 hrate=d->hrate;
360
1/2
✓ Branch 0 taken 114515 times.
✗ Branch 1 not taken.
114515 dstep=d->step;
361 114515 homing=d->homing;
362 114515 dmisc1=d->attributes[0];
363 114515 dmisc2=d->attributes[1];
364 114515 dmisc3=d->attributes[2];
365 114515 dmisc4=d->attributes[3];
366 114515 dmisc5=d->attributes[4];
367 114515 dmisc6=d->attributes[5];
368 114515 dmisc7=d->attributes[6];
369 114515 dmisc8=d->attributes[7];
370 114515 dmisc9=d->attributes[8];
371 114515 dmisc10=d->attributes[9];
372 114515 dmisc11=d->attributes[10];
373 114515 dmisc12=d->attributes[11];
374 114515 dmisc13=d->attributes[12];
375 114515 dmisc14=d->attributes[13];
376 114515 dmisc15=d->attributes[14];
377 114515 dmisc16=d->attributes[15];
378 114515 dmisc17=d->attributes[16];
379 114515 dmisc18=d->attributes[17];
380 114515 dmisc19=d->attributes[18];
381 114515 dmisc20=d->attributes[19];
382 114515 dmisc21=d->attributes[20];
383 114515 dmisc22=d->attributes[21];
384 114515 dmisc23=d->attributes[22];
385 114515 dmisc24=d->attributes[23];
386 114515 dmisc25=d->attributes[24];
387 114515 dmisc26=d->attributes[25];
388 114515 dmisc27=d->attributes[26];
389 114515 dmisc28=d->attributes[27];
390 114515 dmisc29=d->attributes[28];
391 114515 dmisc30=d->attributes[29];
392 114515 dmisc31=d->attributes[30];
393 114515 dmisc32=d->attributes[31];
394
2/2
✓ Branch 0 taken 4074 times.
✓ Branch 1 taken 110441 times.
114515 if (get_qr(qr_BROKEN_ATTRIBUTE_31_32))
395 {
396 110441 dmisc31 = dmisc32;
397 110441 dmisc32 = 0;
398 110441 }
399 114515 spr_shadow=d->spr_shadow;
400 114515 spr_death=d->spr_death;
401 114515 spr_spawn=d->spr_spawn;
402
403
2/2
✓ Branch 0 taken 4695115 times.
✓ Branch 1 taken 114515 times.
4809630 for(int32_t i=0; i<edefLAST255; i++)
404 4695115 defense[i]=d->defense[i];
405
406 114515 bgsfx=d->bgsfx;
407 114515 hitsfx=d->hitsfx;
408 114515 deadsfx=d->deadsfx;
409 114515 bosspal=d->bosspal;
410 114515 parent_script_UID = 0;
411
412 114515 frozentile = d->frozentile;
413
414 114515 frozencset = d->frozencset;
415 114515 frozenclock = 0;
416
2/2
✓ Branch 0 taken 1145150 times.
✓ Branch 1 taken 114515 times.
1259665 for ( int32_t q = 0; q < 10; q++ ) frozenmisc[q] = d->frozenmisc[q];
417
418
2/2
✓ Branch 0 taken 1946755 times.
✓ Branch 1 taken 114515 times.
2061270 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) hitby[q] = 0;
419 //firesfx = 0; //t.b.a -Z
420 114515 isCore = true; //t.b.a
421 114515 parentCore = 0; //t.b.a
422
1/2
✓ Branch 0 taken 114515 times.
✗ Branch 1 not taken.
114515 script_UID = FFCore.GetScriptObjectUID(UID_TYPE_NPC); //This is used by child npcs.
423
424 114515 firesfx = d->firesfx;
425
2/2
✓ Branch 0 taken 3664480 times.
✓ Branch 1 taken 114515 times.
3778995 for ( int32_t q = 0; q < 32; q++ ) movement[q] = d->movement[q];
426
2/2
✓ Branch 0 taken 3664480 times.
✓ Branch 1 taken 114515 times.
3778995 for ( int32_t q = 0; q < 32; q++ ) new_weapon[q] = d->new_weapon[q];
427
428 114515 script = d->script;
429 114515 weaponscript = d->weaponscript;
430
431
2/2
✓ Branch 0 taken 916120 times.
✓ Branch 1 taken 114515 times.
1030635 for ( int32_t q = 0; q < 8; q++ )
432 {
433 916120 initD[q] = d->initD[q];
434 //Z_scripterrlog("(enemy::enemy(zfix)): Loading weapon InitD[%d] to an enemy with a value of (%d)\n",q,d->weap_initiald[q]);
435 916120 weap_initiald[q] = d->weap_initiald[q];
436 916120 }
437
2/2
✓ Branch 0 taken 229030 times.
✓ Branch 1 taken 114515 times.
343545 for ( int32_t q = 0; q < 2; q++ )
438 {
439 229030 initA[q] = d->initA[q];
440 229030 weap_initiala[q] = d->weap_initiala[q];
441 229030 }
442
443 114515 stickclk = 0;
444 114515 submerged = false;
445 114515 didScriptThisFrame = false;
446 114515 ffcactivated = 0;
447 114515 hitdir = -1;
448 114515 dialogue_str = 0; //set by spawn flags.
449 114515 editorflags = d->editorflags; //set by Enemy Editor
450 //Set the drawing flag for this sprite.
451
1/2
✓ Branch 0 taken 114515 times.
✗ Branch 1 not taken.
114515 if ( (editorflags&ENEMY_FLAG12) ) { drawflags |= sprdrawflagALWAYSOLDDRAWS; }
452
453
454
2/2
✓ Branch 0 taken 8858 times.
✓ Branch 1 taken 105657 times.
114515 if(bosspal>-1)
455 {
456
1/2
✓ Branch 0 taken 8858 times.
✗ Branch 1 not taken.
8858 loadpalset(csBOSS,pSprite(bosspal));
457 8858 }
458
459
2/2
✓ Branch 0 taken 49809 times.
✓ Branch 1 taken 64706 times.
114515 if(bgsfx>-1)
460 {
461
1/2
✓ Branch 0 taken 49809 times.
✗ Branch 1 not taken.
49809 cont_sfx(bgsfx);
462 49809 }
463
464
2/2
✓ Branch 0 taken 88395 times.
✓ Branch 1 taken 26120 times.
114515 if(get_qr(qr_NEWENEMYTILES))
465 {
466 88395 o_tile=d->e_tile;
467 88395 frate = d->e_frate;
468 88395 }
469 else
470 {
471 26120 o_tile=d->tile;
472 26120 frate = d->frate;
473 }
474
475 114515 tile=0; //init to 0 here, but set it later.
476
477 114515 scripttile = -1;
478 114515 scriptflip = -1;
479 114515 do_animation = true;
480 114515 immortal = false;
481 114515 noSlide = false;
482 114515 deathexstate = -1;
483
484 114515 hashero=false;
485
486 // If they forgot the invisibility flag, here's another failsafe:
487
4/4
✓ Branch 0 taken 5791 times.
✓ Branch 1 taken 108724 times.
✓ Branch 2 taken 5697 times.
✓ Branch 3 taken 94 times.
114515 if(o_tile==0 && family!=eeSPINTILE)
488
1/2
✓ Branch 0 taken 5697 times.
✗ Branch 1 not taken.
5697 flags |= guy_invisible;
489
490 // step = d->step/100.0;
491 // To preserve the odd step values for Keese & Gleeok heads. -L
492
5/8
✓ Branch 0 taken 114515 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 114515 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 12145 times.
✓ Branch 5 taken 102370 times.
✓ Branch 6 taken 12145 times.
✗ Branch 7 not taken.
114515 if(dstep==62.0) dstep+=0.5;
493
5/8
✓ Branch 0 taken 102370 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 102370 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 699 times.
✓ Branch 5 taken 101671 times.
✓ Branch 6 taken 699 times.
✗ Branch 7 not taken.
102370 else if(dstep==89) dstep-=1/9;
494
495
5/10
✓ Branch 0 taken 114515 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 114515 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 114515 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 114515 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 114515 times.
✗ Branch 9 not taken.
114515 step = zslongToFix(dstep*100);
496
497
498 114515 item_set = d->item_set;
499 114515 grumble = d->grumble;
500
501
2/2
✓ Branch 0 taken 89921 times.
✓ Branch 1 taken 24594 times.
114515 if(frate == 0)
502 24594 frate = 256;
503
504 114515 leader = itemguy = dying = scored = false;
505 114515 canfreeze = count_enemy = true;
506
1/2
✓ Branch 0 taken 114515 times.
✗ Branch 1 not taken.
114515 mainguy = !(flags & guy_doesnt_count);
507
1/2
✓ Branch 0 taken 114515 times.
✗ Branch 1 not taken.
114515 dir = zc_oldrand()&3;
508
509 //2.6 Enemy Editor Hit and TIle Sizes
510
4/6
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 114506 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 9 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 9 times.
114515 if ( ((d->SIZEflags&OVERRIDE_TILE_WIDTH) != 0) && d->txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
511 // al_trace("Enemy txsz:%i\n", txsz);
512
4/6
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 114506 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 9 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 9 times.
114515 if ( ((d->SIZEflags&OVERRIDE_TILE_HEIGHT) != 0) && d->tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
513
3/4
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 114508 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7 times.
114515 if ( ((d->SIZEflags&OVERRIDE_HIT_WIDTH) != 0) && d->hxsz >= 0 ) hit_width = d->hxsz;
514
3/4
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 114508 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7 times.
114515 if ( ((d->SIZEflags&OVERRIDE_HIT_HEIGHT) != 0) && d->hysz >= 0 ) hit_height = d->hysz;
515
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 114515 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
114515 if ( ((d->SIZEflags&OVERRIDE_HIT_Z_HEIGHT) != 0) && d->hzsz >= 0 ) hzsz = d->hzsz;
516
1/2
✓ Branch 0 taken 114515 times.
✗ Branch 1 not taken.
114515 if ( (d->SIZEflags&OVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
517
1/2
✓ Branch 0 taken 114515 times.
✗ Branch 1 not taken.
114515 if ( (d->SIZEflags&OVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
518 // if ( (d->SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = d->hzofs;
519
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 114515 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
114515 if ( (d->SIZEflags&OVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)d->xofs;
520
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 114515 times.
114515 if ( (d->SIZEflags&OVERRIDE_DRAW_Y_OFFSET) != 0 )
521 {
522 yofs = (int32_t)d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
523 yofs += (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
524 }
525
526
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 114515 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
114515 if ( (d->SIZEflags&OVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)d->zofs;
527
528 114515 SIZEflags = d->SIZEflags;
529
530
8/10
✓ Branch 0 taken 114266 times.
✓ Branch 1 taken 249 times.
✓ Branch 2 taken 366 times.
✓ Branch 3 taken 114149 times.
✓ Branch 4 taken 366 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 366 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1 times.
✓ Branch 9 taken 365 times.
114515 if((wpn==ewBomb || wpn==ewSBomb) && family!=eeOTHER && family!=eeFIRE && (family!=eeWALK || dmisc2 != e2tBOMBCHU))
531 1 wpn = 0;
532
533 //tile should never be 0 after init --Z (failsafe)
534
4/6
✓ Branch 0 taken 114515 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 114515 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 107954 times.
✓ Branch 5 taken 6561 times.
114515 if (tile <= 0 && FFCore.getQuestHeaderInfo(vZelda) >= 0x255) {tile = o_tile;}
535
536 //Moveflags; for gravity and pit interaction
537 114515 moveflags = d->moveflags;
538
3/4
✓ Branch 0 taken 114515 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 17659 times.
✓ Branch 3 taken 96856 times.
114515 if(!can_pitfall(false))
539 {
540 //Some enemies must not interact with pits. Force their flags, for sanity's sake.
541
2/4
✓ Branch 0 taken 17659 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 17659 times.
✗ Branch 3 not taken.
17659 moveflags &= ~move_can_pitfall;
542
2/4
✓ Branch 0 taken 17659 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 17659 times.
✗ Branch 3 not taken.
17659 moveflags &= ~move_can_waterdrown;
543 17659 }
544
545 114515 shieldCanBlock = get_qr(qr_GOHMA_UNDAMAGED_BUG)?true:false;
546
547
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 114515 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
114515 if (((d->weapoverrideFLAGS & OVERRIDE_TILE_WIDTH) != 0) && d->weap_tilew > 0) { weap_tilew = d->weap_tilew; if (weap_tilew > 1) extend = 3; }
548
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 114515 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
114515 if (((d->weapoverrideFLAGS & OVERRIDE_TILE_HEIGHT) != 0) && d->weap_tileh > 0) { weap_tileh = d->weap_tileh; if (weap_tileh > 1) extend = 3; }
549
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 114515 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
114515 if (((d->weapoverrideFLAGS & OVERRIDE_HIT_WIDTH) != 0) && d->weap_hxsz >= 0) weap_hxsz = d->weap_hxsz;
550
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 114515 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
114515 if (((d->weapoverrideFLAGS & OVERRIDE_HIT_HEIGHT) != 0) && d->weap_hysz >= 0) weap_hysz = d->weap_hysz;
551
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 114515 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
114515 if (((d->weapoverrideFLAGS & OVERRIDE_HIT_Z_HEIGHT) != 0) && d->weap_hzsz >= 0) weap_hzsz = d->weap_hzsz;
552
1/2
✓ Branch 0 taken 114515 times.
✗ Branch 1 not taken.
114515 if ((d->weapoverrideFLAGS & OVERRIDE_HIT_X_OFFSET) != 0) weap_hxofs = d->weap_hxofs;
553
1/2
✓ Branch 0 taken 114515 times.
✗ Branch 1 not taken.
114515 if ((d->weapoverrideFLAGS & OVERRIDE_HIT_Y_OFFSET) != 0) weap_hyofs = d->weap_hyofs;
554
1/2
✓ Branch 0 taken 114515 times.
✗ Branch 1 not taken.
114515 if ((d->weapoverrideFLAGS & OVERRIDE_DRAW_X_OFFSET) != 0) weap_xofs = (int32_t)d->weap_xofs;
555
1/2
✓ Branch 0 taken 114515 times.
✗ Branch 1 not taken.
114515 if ((d->weapoverrideFLAGS & OVERRIDE_DRAW_Y_OFFSET) != 0)
556 {
557 weap_yofs = (int32_t)d->weap_yofs; //This seems to be setting to +48 or something with any value set?! -Z
558 weap_yofs += (get_qr(qr_OLD_DRAWOFFSET) ? playing_field_offset : original_playing_field_offset); //this offset fixes yofs not plaing properly. -Z
559 }
560 114515 weapoverrideFLAGS = d->weapoverrideFLAGS;
561 114515 wunblockable = d->wunblockable;
562 114515 wmoveflags = d->wmoveflags;
563
2/4
✓ Branch 0 taken 114515 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 114515 times.
✗ Branch 3 not taken.
114515 wstep = zslongToFix(d->wstep*100);
564
2/2
✓ Branch 0 taken 572575 times.
✓ Branch 1 taken 114515 times.
687090 for (int q=0; q < WPNSPR_MAX; ++q)
565 {
566 572575 burnsprs[q] = d->burnsprs[q];
567 572575 light_rads[q] = d->light_rads[q];
568 572575 }
569 114515 }
570
571 598 int32_t enemy::getScriptUID() { return script_UID; }
572 void enemy::setScriptUID(int32_t new_id) { script_UID = new_id; }
573 114285 enemy::~enemy()
574 114285 {
575
2/4
✓ Branch 0 taken 114285 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 114285 times.
✗ Branch 3 not taken.
114285 FFCore.deallocateAllScriptOwned(ScriptType::NPC, getUID());
576
2/2
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 114272 times.
114285 if(hashero)
577 {
578
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 Hero.setEaten(0);
579 13 hashero=false;
580 13 }
581 114285 }
582
583 bool enemy::is_move_paused()
584 {
585 return (clk<0 || dying || stunclk || watch || ceiling || frozenclock || fallclk || drownclk);
586 }
587
588 7024 bool enemy::scr_walkflag(int32_t dx,int32_t dy,int32_t special, int32_t dir, int32_t input_x, int32_t input_y, bool kb)
589 {
590 7024 int32_t yg = (special==spw_floater)?8:0;
591 7024 int32_t nb = get_qr(qr_NOBORDER) ? 16 : 0;
592 //Z_eventlog("Checking x,y %d,%d\n",dx,dy);
593
1/2
✓ Branch 0 taken 7024 times.
✗ Branch 1 not taken.
7024 if(input_x == -1000)
594 input_x = dx;
595
1/2
✓ Branch 0 taken 7024 times.
✗ Branch 1 not taken.
7024 if(input_y == -1000)
596 input_y = dy;
597
598
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7024 times.
14048 if(!(moveflags & move_ignore_screenedge)
599
4/6
✓ Branch 0 taken 7024 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 7024 times.
✓ Branch 4 taken 6707 times.
✓ Branch 5 taken 317 times.
7024 && ((input_x<(16-nb)) || (input_y<zc_max(16-yg-nb,0))
600
2/4
✓ Branch 0 taken 7024 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7024 times.
✗ Branch 3 not taken.
7024 || ((input_x+hit_width-1) >= (240+nb)) || ((input_y+hit_height-1) >= (160+nb))))
601 return true;
602
603
4/6
✓ Branch 0 taken 90 times.
✓ Branch 1 taken 6934 times.
✓ Branch 2 taken 90 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 90 times.
✗ Branch 5 not taken.
7024 if(!(moveflags & move_can_pitwalk) && (!(moveflags & move_can_pitfall) || !kb)) //Don't walk into pits, unless being knocked back
604 {
605 if(ispitfall(dx,dy))
606 return true;
607 }
608
609 7024 bool flying = false;
610 7024 bool cansolid = false;
611
1/2
✓ Branch 0 taken 7024 times.
✗ Branch 1 not taken.
7024 if(moveflags & move_ignore_solidity)
612 cansolid = true;
613
2/4
✓ Branch 0 taken 317 times.
✓ Branch 1 taken 6707 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
7024 switch(special)
614 {
615 case spw_clipbottomright:
616 if(dy>=128 || dx>=208) return true;
617 break;
618 case spw_clipright:
619 break; //if(input_x>=208) return true; break;
620
621 case spw_wizzrobe: // fall through
622 case spw_floater: // Special case for fliers and wizzrobes - hack!
623 {
624
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 317 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
317 if(isdungeon() && !(moveflags & move_ignore_screenedge))
625 {
626 if(dy < 32-yg || dy >= 144) return true;
627 if(dx < 32 || dx >= 224) return true;
628 }
629
2/4
✓ Branch 0 taken 317 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 317 times.
✗ Branch 3 not taken.
317 if(!(moveflags & move_ignore_blockflags) && flyerblocked(dx, dy, special, kb))
630 return true;
631 317 cansolid = true;
632 317 flying = true;
633 }
634 317 }
635
636 7024 dx &= ~7;
637 7024 dy &= ~7;
638
639
4/6
✓ Branch 0 taken 6707 times.
✓ Branch 1 taken 317 times.
✓ Branch 2 taken 6707 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 6707 times.
✗ Branch 5 not taken.
7024 if(!flying && !(moveflags & move_ignore_blockflags) && groundblocked(dx,dy,kb)) return true;
640
641
4/8
✓ Branch 0 taken 7024 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7024 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 7024 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 7024 times.
7024 if (dx < 0 || dx > 255 || dy < 0 || dy > 175)
642 return !(moveflags & move_ignore_screenedge);
643 //_walkflag code
644 mapscr *s1, *s2;
645 7024 s1=(((*tmpscr).layermap[0]-1)>=0)?tmpscr2:NULL;
646 7024 s2=(((*tmpscr).layermap[1]-1)>=0)?tmpscr2+1:NULL;
647
648 7024 int32_t cpos=(dx>>4)+(dy&0xF0);
649
3/4
✓ Branch 0 taken 7024 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1038 times.
✓ Branch 3 taken 5986 times.
7024 int32_t ci = tmpscr->data[cpos], ci1 = (s1?s1:tmpscr)->data[cpos], ci2 = (s2?s2:tmpscr)->data[cpos];
650 7024 newcombo const& c = combobuf[ci];
651 7024 newcombo const& c1 = combobuf[ci1];
652 7024 newcombo const& c2 = combobuf[ci2];
653
654 7024 int32_t b=1;
655
2/2
✓ Branch 0 taken 3446 times.
✓ Branch 1 taken 3578 times.
7024 if(dx&8) b<<=2;
656
2/2
✓ Branch 0 taken 3374 times.
✓ Branch 1 taken 3650 times.
7024 if(dy&8) b<<=1;
657
658 #define iwtr(cmb, x, y, shallow) \
659 (shallow \
660 ? iswaterex(cmb, currmap, currscr, -1, dx, dy, false, false, false, true, false) \
661 && !iswaterex(cmb, currmap, currscr, -1, dx, dy, false, false, false, false, false) \
662 : iswaterex(cmb, currmap, currscr, -1, dx, dy, false, false, false, false, false))
663 7024 bool wtr = iwtr(ci, dx, dy, false);
664
2/2
✓ Branch 0 taken 3551 times.
✓ Branch 1 taken 3473 times.
7024 bool shwtr = iwtr(ci, dx, dy, true);
665 7024 bool pit = ispitfall(dx,dy);
666
667
3/4
✓ Branch 0 taken 6934 times.
✓ Branch 1 taken 90 times.
✓ Branch 2 taken 90 times.
✗ Branch 3 not taken.
7024 bool canwtr = (moveflags & move_can_waterwalk) || ((moveflags & move_can_waterdrown) && kb);
668
3/4
✓ Branch 0 taken 6934 times.
✓ Branch 1 taken 90 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 90 times.
7024 bool canpit = (moveflags & move_can_pitwalk) || ((moveflags & move_can_pitfall) && kb);
669 7024 bool needwtr = (moveflags & move_only_waterwalk);
670 7024 bool needshwtr = (moveflags & move_only_shallow_waterwalk);
671 7024 bool needpit = (moveflags & move_only_pitwalk);
672
673
2/2
✓ Branch 0 taken 317 times.
✓ Branch 1 taken 6707 times.
7024 if(!cansolid)
674 {
675 6707 int32_t cwalkflag = c.walk & 0xF;
676
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6707 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
6707 if (c.type == cBRIDGE && get_qr(qr_OLD_BRIDGE_COMBOS)) cwalkflag = 0;
677
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6707 times.
6707 if (s1)
678 {
679
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6707 times.
6707 if (c1.type == cBRIDGE)
680 {
681 if (!get_qr(qr_OLD_BRIDGE_COMBOS))
682 {
683 int efflag = (c1.walk & 0xF0)>>4;
684 int newsolid = (c1.walk & 0xF);
685 cwalkflag = ((newsolid | cwalkflag) & (~efflag)) | (newsolid & efflag);
686 }
687 else cwalkflag &= c1.walk;
688 }
689 6707 else cwalkflag |= c1.walk & 0xF;
690 6707 }
691
2/2
✓ Branch 0 taken 5986 times.
✓ Branch 1 taken 721 times.
6707 if (s2)
692 {
693
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 721 times.
721 if (c2.type == cBRIDGE)
694 {
695 if (!get_qr(qr_OLD_BRIDGE_COMBOS))
696 {
697 int efflag = (c2.walk & 0xF0)>>4;
698 int newsolid = (c2.walk & 0xF);
699 cwalkflag = ((newsolid | cwalkflag) & (~efflag)) | (newsolid & efflag);
700 }
701 else cwalkflag &= c2.walk;
702 }
703 721 else cwalkflag |= c2.walk & 0xF;
704 721 }
705
2/2
✓ Branch 0 taken 239 times.
✓ Branch 1 taken 6468 times.
6707 if(cwalkflag & b)
706 239 return true;
707 6468 }
708
3/6
✓ Branch 0 taken 6785 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6785 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 6785 times.
6785 if(needwtr || needshwtr || needpit)
709 {
710 bool ret = true;
711 if (needwtr && wtr) ret = false;
712 else if (needshwtr && shwtr) ret = false;
713 else if (needpit && pit) ret = false;
714 return ret;
715 }
716
3/4
✓ Branch 0 taken 3473 times.
✓ Branch 1 taken 3312 times.
✓ Branch 2 taken 3473 times.
✗ Branch 3 not taken.
6785 else if(wtr && !canwtr)
717 return true;
718
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6785 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
6785 else if(pit && !canpit)
719 return true;
720
721 6785 return false;
722 7024 }
723
724 1535 bool enemy::scr_canmove(zfix dx, zfix dy, int32_t special, bool kb, bool ign_sv)
725 {
726
3/4
✓ Branch 0 taken 424 times.
✓ Branch 1 taken 1111 times.
✓ Branch 2 taken 424 times.
✗ Branch 3 not taken.
1535 if(!(dx || dy)) return true;
727 1535 zfix bx = x+hxofs, by = y+hyofs; //left/top
728 1535 zfix rx = bx+hit_width-1, ry = by+hit_height-1; //right/bottom
729
3/4
✓ Branch 0 taken 1019 times.
✓ Branch 1 taken 516 times.
✓ Branch 2 taken 1019 times.
✗ Branch 3 not taken.
1535 if(!ign_sv && dy < 0) //check gravity
730 {
731 if((moveflags & move_obeys_grav) && isSideViewGravity())
732 return false;
733 }
734
735
2/4
✓ Branch 0 taken 1535 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1535 times.
1535 bool nosolid = !((moveflags & move_ignore_solidity) || (special==spw_wizzrobe) || (special==spw_floater));
736
737
3/4
✓ Branch 0 taken 1111 times.
✓ Branch 1 taken 424 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1111 times.
1535 if(dx && !dy)
738 {
739
2/2
✓ Branch 0 taken 770 times.
✓ Branch 1 taken 341 times.
1111 if(dx < 0)
740 {
741
2/4
✓ Branch 0 taken 770 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 770 times.
770 special = (special==spw_clipbottomright||special==spw_clipright)?spw_none:special;
742 770 int mx = (bx+dx).getFloor();
743
2/2
✓ Branch 0 taken 2976 times.
✓ Branch 1 taken 770 times.
3746 for(zfix ty = 0; by+ty < ry; ty += 8)
744 {
745
1/2
✓ Branch 0 taken 2976 times.
✗ Branch 1 not taken.
2976 if(scr_walkflag(mx, by+ty, special, left, mx, by, kb))
746 return false;
747 2976 }
748
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 770 times.
770 if(scr_walkflag(mx, ry, special, left, mx, by, kb))
749 return false;
750
3/4
✓ Branch 0 taken 736 times.
✓ Branch 1 taken 34 times.
✓ Branch 2 taken 736 times.
✗ Branch 3 not taken.
770 if(nosolid && collide_object(bx+dx,by,-dx,hit_height,this))
751 return false;
752 770 }
753 else
754 {
755 341 int mx = (rx+dx).getCeil();
756 341 int lx = mx-hit_width+1;
757
2/2
✓ Branch 0 taken 2142 times.
✓ Branch 1 taken 340 times.
2482 for(zfix ty = 0; by+ty < ry; ty += 8)
758 {
759
2/2
✓ Branch 0 taken 2141 times.
✓ Branch 1 taken 1 times.
2142 if(scr_walkflag(mx, by+ty, special, right, lx, by, kb))
760 1 return false;
761 2141 }
762
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 340 times.
340 if(scr_walkflag(mx, ry, special, right, lx, by, kb))
763 return false;
764
2/4
✓ Branch 0 taken 340 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 340 times.
✗ Branch 3 not taken.
340 if(nosolid && collide_object(bx+hit_width,by,dx,hit_height,this))
765 return false;
766 }
767 1110 }
768
2/4
✓ Branch 0 taken 424 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 424 times.
424 else if(dy && !dx)
769 {
770
2/2
✓ Branch 0 taken 315 times.
✓ Branch 1 taken 109 times.
424 if(dy < 0)
771 {
772
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 315 times.
315 special = (special==spw_clipbottomright)?spw_none:special;
773 315 int my = (by+dy).getFloor();
774
2/2
✓ Branch 0 taken 392 times.
✓ Branch 1 taken 77 times.
469 for(zfix tx = 0; bx+tx < rx; tx += 8)
775 {
776
2/2
✓ Branch 0 taken 154 times.
✓ Branch 1 taken 238 times.
392 if(scr_walkflag(bx+tx, my, special, up, bx, my, kb))
777 238 return false;
778 154 }
779
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 77 times.
77 if(scr_walkflag(rx, my, special, up, bx, my, kb))
780 return false;
781
3/4
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 63 times.
✓ Branch 2 taken 14 times.
✗ Branch 3 not taken.
77 if(nosolid && collide_object(bx,by+dy,hit_width,-dy,this))
782 return false;
783 77 }
784 else
785 {
786 109 int my = (ry+dy).getCeil();
787 109 int ly = my-hit_height+1;
788
2/2
✓ Branch 0 taken 218 times.
✓ Branch 1 taken 109 times.
327 for(zfix tx = 0; bx+tx < rx; tx += 8)
789 {
790
1/2
✓ Branch 0 taken 218 times.
✗ Branch 1 not taken.
218 if(scr_walkflag(bx+tx, my, special, down, bx, ly, kb))
791 return false;
792 218 }
793
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 109 times.
109 if(scr_walkflag(rx, my, special, down, bx, ly, kb))
794 return false;
795
3/4
✓ Branch 0 taken 89 times.
✓ Branch 1 taken 20 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 89 times.
109 if(nosolid && collide_object(bx,by+hit_height,hit_width,dy,this))
796 return false;
797 }
798 186 }
799 else //! Untested, and currently unused.
800 {
801 return scr_canmove(dx, 0, special, kb, ign_sv) && scr_canmove(dy, 0, special, kb, ign_sv);
802 }
803 1296 return true;
804 1535 }
805
806 bool enemy::scr_canplace(zfix dx, zfix dy, int32_t special, bool kb)
807 {
808 zfix bx = dx+hxofs, by = dy+hyofs; //left/top
809 zfix rx = bx+hit_width-1, ry = by+hit_height-1; //right/bottom
810
811 bool nosolid = !((moveflags & move_ignore_solidity) || (special==spw_wizzrobe) || (special==spw_floater));
812
813 if(nosolid && collide_object(bx,by,hit_width,hit_height,this))
814 return false;
815 for(zfix ty = 0; by+ty < ry; ty += 8)
816 {
817 for(zfix tx = 0; bx+tx < rx; tx += 8)
818 {
819 if(scr_walkflag(bx+tx, by+ty, special, -1, -1000, -1000, kb))
820 return false;
821 }
822 if(scr_walkflag(rx, by+ty, special, -1, -1000, -1000, kb))
823 return false;
824 }
825 for(zfix tx = 0; bx+tx < rx; tx += 8)
826 {
827 if(scr_walkflag(bx+tx, ry, special, -1, -1000, -1000, kb))
828 return false;
829 }
830 if(scr_walkflag(rx, ry, special, -1, -1000, -1000, kb))
831 return false;
832 return true;
833 }
834
835 bool enemy::scr_canplace(zfix dx, zfix dy, int32_t special, bool kb, int32_t nwid, int32_t nhei)
836 {
837 auto oxsz = hit_width, oysz = hit_height;
838 if(nwid > -1) hit_width = nwid;
839 if(nhei > -1) hit_height = nhei;
840 bool ret = scr_canplace(dx,dy,special,kb);
841 hit_width = oxsz; hit_height = oysz;
842 return ret;
843 }
844
845 1311 bool enemy::movexy(zfix dx, zfix dy, int32_t special, bool kb, bool ign_sv, bool earlyret)
846 {
847 1311 bool ret = true;
848
3/8
✓ Branch 0 taken 1019 times.
✓ Branch 1 taken 292 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1019 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
1311 if(!ign_sv && dy < 0 && (moveflags & move_obeys_grav) && isSideViewGravity())
849 dy = 0;
850 1311 const int scl = 2;
851
4/4
✓ Branch 0 taken 260 times.
✓ Branch 1 taken 1345 times.
✓ Branch 2 taken 294 times.
✓ Branch 3 taken 1311 times.
1605 while(abs(dx) > scl || abs(dy) > scl)
852 {
853
2/2
✓ Branch 0 taken 260 times.
✓ Branch 1 taken 34 times.
294 if(abs(dx) > abs(dy))
854 {
855 260 int32_t tdx = dx.sign() * scl;
856
1/2
✓ Branch 0 taken 260 times.
✗ Branch 1 not taken.
260 if(movexy(tdx, 0, special, kb, ign_sv, earlyret))
857 260 dx -= tdx;
858 else
859 {
860 if(earlyret) return false;
861 dx = tdx;
862 ret = false;
863 }
864 260 }
865 else
866 {
867 34 int32_t tdy = dy.sign() * scl;
868
2/2
✓ Branch 0 taken 27 times.
✓ Branch 1 taken 7 times.
34 if(movexy(0, tdy, special, kb, ign_sv, earlyret))
869 27 dy -= tdy;
870 else
871 {
872
1/2
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
7 if(earlyret) return false;
873 7 dy = tdy;
874 7 ret = false;
875 }
876 }
877 }
878
879
2/2
✓ Branch 0 taken 200 times.
✓ Branch 1 taken 1111 times.
1311 if(dx)
880 {
881
2/2
✓ Branch 0 taken 1110 times.
✓ Branch 1 taken 1 times.
1111 if(scr_canmove(dx, 0, special, kb, ign_sv))
882 1110 x += dx;
883 else
884 {
885
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(earlyret) return false;
886 ret = false;
887 int xsign = dx.sign();
888 while(scr_canmove(xsign, 0, special, kb, ign_sv))
889 {
890 x += xsign;
891 dx -= xsign;
892 }
893 if(dx)
894 {
895 dx.doDecBound(0,-9999, 0,9999);
896 dx = binary_search_zfix(dx.decsign(), dx, [&](zfix val, zfix& retval){
897 if(scr_canmove(val, 0, special, kb, ign_sv))
898 {
899 retval = val;
900 return BSEARCH_CONTINUE_AWAY0;
901 }
902 else return BSEARCH_CONTINUE_TOWARD0;
903 });
904 x += dx;
905 }
906 }
907 1110 }
908
2/2
✓ Branch 0 taken 1110 times.
✓ Branch 1 taken 200 times.
1310 if(dy)
909 {
910
2/2
✓ Branch 0 taken 186 times.
✓ Branch 1 taken 14 times.
200 if(scr_canmove(0, dy, special, kb, ign_sv))
911 186 y += dy;
912 else
913 {
914
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(earlyret) return false;
915 14 ret = false;
916 14 int ysign = dy.sign();
917
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 while(scr_canmove(0, ysign, special, kb, ign_sv))
918 {
919 y += ysign;
920 dy -= ysign;
921 }
922
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(dy)
923 {
924 14 dy.doDecBound(0,-9999, 0,9999);
925
3/6
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 14 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 14 times.
✗ Branch 5 not taken.
224 dy = binary_search_zfix(dy.decsign(), dy, [&](zfix val, zfix& retval){
926
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 210 times.
210 if(scr_canmove(0, val, special, kb, ign_sv))
927 {
928 retval = val;
929 return BSEARCH_CONTINUE_AWAY0;
930 }
931 210 else return BSEARCH_CONTINUE_TOWARD0;
932 210 });
933 14 y += dy;
934 14 }
935 }
936 200 }
937 1310 return ret;
938 1311 }
939
940 754 bool enemy::moveDir(int32_t dir, zfix px, int32_t special, bool kb, bool earlyret)
941 {
942
4/6
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 752 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
754 static const zfix diagrate = zslongToFix(7071);
943
5/13
✓ Branch 0 taken 754 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 754 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 16 times.
✓ Branch 6 taken 479 times.
✓ Branch 7 taken 259 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
754 switch(NORMAL_DIR(dir))
944 {
945 case up:
946 return movexy(0, -px, special, kb, false, earlyret);
947 case down:
948 16 return movexy(0, px, special, kb, false, earlyret);
949 case left:
950 479 return movexy(-px, 0, special, kb, false, earlyret);
951 case right:
952 259 return movexy(px, 0, special, kb, false, earlyret);
953 case r_up:
954 return movexy(px*diagrate, -px*diagrate, special, kb, false, earlyret);
955 case r_down:
956 return movexy(px*diagrate, px*diagrate, special, kb, false, earlyret);
957 case l_up:
958 return movexy(-px*diagrate, -px*diagrate, special, kb, false, earlyret);
959 case l_down:
960 return movexy(-px*diagrate, px*diagrate, special, kb, false, earlyret);
961 }
962 return false;
963 754 }
964
965 bool enemy::moveAtAngle(zfix degrees, zfix px, int32_t special, bool kb, bool earlyret)
966 {
967 double v = degrees.getFloat() * PI / 180.0;
968 zfix dx = zc::math::Cos(v)*px, dy = zc::math::Sin(v)*px;
969 return movexy(dx, dy, special, kb, false, earlyret);
970 }
971
972 bool enemy::can_movexy(zfix dx, zfix dy, int32_t special, bool kb)
973 {
974 zfix tx = x, ty = y;
975 bool ret = movexy(dx, dy, special, kb, false, true);
976 x = tx;
977 y = ty;
978 return ret;
979 }
980 754 bool enemy::can_moveDir(int32_t dir, zfix px, int32_t special, bool kb)
981 {
982 754 zfix tx = x, ty = y;
983 754 bool ret = moveDir(dir, px, special, kb, true);
984 754 x = tx;
985 754 y = ty;
986 754 return ret;
987 }
988 bool enemy::can_moveAtAngle(zfix degrees, zfix px, int32_t special, bool kb)
989 {
990 zfix tx = x, ty = y;
991 bool ret = moveAtAngle(degrees, px, special, kb, true);
992 x = tx;
993 y = ty;
994 return ret;
995 }
996
997 // Handle pitfalls
998 37823959 bool enemy::do_falling(int32_t index)
999 {
1000
2/2
✓ Branch 0 taken 37821661 times.
✓ Branch 1 taken 2298 times.
37823959 if(fallclk > 0)
1001 {
1002
4/4
✓ Branch 0 taken 33 times.
✓ Branch 1 taken 2265 times.
✓ Branch 2 taken 13 times.
✓ Branch 3 taken 20 times.
2298 if(fallclk == PITFALL_FALL_FRAMES && fallCombo) sfx(combobuf[fallCombo].attribytes[0], pan(x.getInt()));
1003
2/2
✓ Branch 0 taken 2276 times.
✓ Branch 1 taken 22 times.
2298 if(!--fallclk)
1004 {
1005
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22 times.
22 if(immortal) //Keep alive forever
1006 ++fallclk; //force another frame of falling.... forever.
1007
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 11 times.
22 else if(dying) //Give 1 frame for script revival
1008 {
1009
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if(flags&guy_never_return)
1010 never_return(index);
1011
1012
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if(leader)
1013 kill_em_all();
1014
1015 //leave_item(); //Don't drop items in pits!
1016 11 stop_bgsfx(index);
1017 11 return true;
1018 }
1019 else
1020 {
1021 11 try_death(true); //Force death
1022 11 ++fallclk; //force another frame of falling
1023 }
1024 11 }
1025
1026 2287 wpndata& spr = wpnsbuf[QMisc.sprites[sprFALL]];
1027 2287 cs = spr.csets & 0xF;
1028
1/2
✓ Branch 0 taken 2287 times.
✗ Branch 1 not taken.
2287 int32_t fr = spr.frames ? spr.frames : 1;
1029
1/2
✓ Branch 0 taken 2287 times.
✗ Branch 1 not taken.
2287 int32_t spd = spr.speed ? spr.speed : 1;
1030 2287 int32_t animclk = (PITFALL_FALL_FRAMES-fallclk);
1031
2/2
✓ Branch 0 taken 1101 times.
✓ Branch 1 taken 1186 times.
2287 tile = spr.tile + zc_min(animclk / spd, fr-1);
1032 2287 }
1033 37823948 return false;
1034 37823959 }
1035
1036 // Handle drowning in water
1037 37821661 bool enemy::do_drowning(int32_t index)
1038 {
1039
1/2
✓ Branch 0 taken 37821661 times.
✗ Branch 1 not taken.
37821661 if(drownclk > 0)
1040 {
1041 //if(drownclk == WATER_DROWN_FRAMES && drownCombo) sfx(combobuf[drownCombo].attribytes[0], pan(x.getInt()));
1042 //!TODO: Drown SFX
1043 if(!--drownclk)
1044 {
1045 if(immortal) //Keep alive forever
1046 ++drownclk; //force another frame of falling.... forever.
1047 else if(dying) //Give 1 frame for script revival
1048 {
1049 if(flags&guy_never_return)
1050 never_return(index);
1051
1052 if(leader)
1053 kill_em_all();
1054
1055 //leave_item(); //Don't drop items in pits!
1056 stop_bgsfx(index);
1057 return true;
1058 }
1059 else
1060 {
1061 try_death(true); //Force death
1062 ++drownclk; //force another frame of falling
1063 }
1064 }
1065
1066 if (drownCombo && combobuf[drownCombo].usrflags&cflag1)
1067 {
1068 wpndata &spr = wpnsbuf[QMisc.sprites[sprLAVADROWN]];
1069 cs = spr.csets & 0xF;
1070 int32_t fr = spr.frames ? spr.frames : 1;
1071 int32_t spd = spr.speed ? spr.speed : 1;
1072 int32_t animclk = (WATER_DROWN_FRAMES-drownclk);
1073 tile = spr.tile + zc_min((animclk % (spd*fr))/spd, fr-1);
1074 }
1075 else
1076 {
1077 wpndata &spr = wpnsbuf[QMisc.sprites[sprDROWN]];
1078 cs = spr.csets & 0xF;
1079 int32_t fr = spr.frames ? spr.frames : 1;
1080 int32_t spd = spr.speed ? spr.speed : 1;
1081 int32_t animclk = (WATER_DROWN_FRAMES-drownclk);
1082 tile = spr.tile + zc_min((animclk % (spd*fr))/spd, fr-1);
1083 }
1084 }
1085 37821661 return false;
1086 37821661 }
1087
1088 // Supplemental animation code that all derived classes should call
1089 // as a return value for animate().
1090 // Handles the death animation and returns true when enemy is finished.
1091 38486231 bool enemy::Dead(int32_t index)
1092 {
1093
2/2
✓ Branch 0 taken 1829 times.
✓ Branch 1 taken 38484402 times.
38486231 if(immortal)
1094 {
1095 1829 dying = false;
1096 1829 return false;
1097 }
1098
2/2
✓ Branch 0 taken 762989 times.
✓ Branch 1 taken 37721413 times.
38484402 if(dying)
1099 {
1100
3/4
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 762988 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
762989 if(deathexstate > -1 && deathexstate < 32)
1101 {
1102 1 setxmapflag(1<<deathexstate);
1103 1 deathexstate = -1;
1104 1 }
1105 762989 --clk2;
1106
1107
4/4
✓ Branch 0 taken 723363 times.
✓ Branch 1 taken 39626 times.
✓ Branch 2 taken 38635 times.
✓ Branch 3 taken 3195 times.
762989 if((get_qr(qr_HARDCODED_ENEMY_ANIMS) && clk2==12)
1108
2/2
✓ Branch 0 taken 41830 times.
✓ Branch 1 taken 681533 times.
723363 && hp>-1000) // not killed by ringleader
1109 38635 death_sfx();
1110
1111
2/2
✓ Branch 0 taken 719613 times.
✓ Branch 1 taken 43376 times.
762989 if(clk2==0)
1112 {
1113
2/2
✓ Branch 0 taken 42672 times.
✓ Branch 1 taken 704 times.
43376 if(flags&guy_never_return)
1114 704 never_return(index);
1115
1116
2/2
✓ Branch 0 taken 43305 times.
✓ Branch 1 taken 71 times.
43376 if(leader)
1117 71 kill_em_all();
1118
1119 43376 leave_item();
1120 43376 }
1121
1122 762989 stop_bgsfx(index);
1123 762989 return (clk2==0);
1124 }
1125
1126 37721413 return false;
1127 38486231 }
1128
1129 // Basic animation code that all derived classes should call.
1130 // The one with an index is the one that is called by
1131 // the guys sprite list; index is the enemy's index in the list.
1132 37824215 bool enemy::animate(int32_t index)
1133 {
1134
2/2
✓ Branch 0 taken 1683411 times.
✓ Branch 1 taken 36140804 times.
37824215 if(sclk <= 0) hitdir = -1;
1135
2/2
✓ Branch 0 taken 256 times.
✓ Branch 1 taken 37823959 times.
37824215 if(switch_hooked)
1136 {
1137
1/2
✓ Branch 0 taken 256 times.
✗ Branch 1 not taken.
256 if(get_qr(qr_SWITCHOBJ_RUN_SCRIPT))
1138 {
1139 //Run its script
1140 if (!didScriptThisFrame)
1141 {
1142 if (runscript_do_earlyret(run_script(MODE_NORMAL)))
1143 {
1144 return 0; //Avoid NULLPO if this object deleted itself
1145 }
1146 }
1147 }
1148 256 return false;
1149 }
1150
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 37823948 times.
37823959 if(do_falling(index)) return true;
1151
2/2
✓ Branch 0 taken 2287 times.
✓ Branch 1 taken 37821661 times.
37823948 else if(fallclk)
1152 {
1153 //clks
1154
2/2
✓ Branch 0 taken 1611 times.
✓ Branch 1 taken 676 times.
2287 if(hclk>0)
1155 676 --hclk;
1156
1/2
✓ Branch 0 taken 2287 times.
✗ Branch 1 not taken.
2287 if(stunclk>0)
1157 --stunclk;
1158
1/2
✓ Branch 0 taken 2287 times.
✗ Branch 1 not taken.
2287 if ( frozenclock > 0 )
1159 --frozenclock;
1160
1/2
✓ Branch 0 taken 2287 times.
✗ Branch 1 not taken.
2287 if(hashero)
1161 {
1162 Hero.setX(x);
1163 Hero.setY(y);
1164 Hero.fallCombo = fallCombo;
1165 Hero.fallclk = fallclk;
1166 hashero = false; //Let Hero go if falling
1167 }
1168
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2287 times.
2287 if (!didScriptThisFrame)
1169 {
1170 2287 run_script(MODE_NORMAL);
1171 2287 }
1172 2287 return false;
1173 }
1174
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 37821661 times.
37821661 if(do_drowning(index)) return true;
1175
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 37821661 times.
37821661 else if(drownclk)
1176 {
1177 //clks
1178 if(hclk>0)
1179 --hclk;
1180 if(stunclk>0)
1181 --stunclk;
1182 if ( frozenclock > 0 )
1183 --frozenclock;
1184 if(hashero)
1185 {
1186 Hero.setX(x);
1187 Hero.setY(y);
1188 Hero.drownclk = drownclk;
1189 hashero = false; //Let Hero go if falling
1190 }
1191 if (!didScriptThisFrame)
1192 {
1193 run_script(MODE_NORMAL);
1194 }
1195 return false;
1196 }
1197 37821661 int32_t nx = real_x(x);
1198 37821661 int32_t ny = real_y(y);
1199
1200
4/4
✓ Branch 0 taken 27354947 times.
✓ Branch 1 taken 10466714 times.
✓ Branch 2 taken 5643282 times.
✓ Branch 3 taken 21711665 times.
37821661 if(ox!=nx || oy!=ny)
1201 {
1202 16109996 posframe=(posframe+1)%(get_qr(qr_NEWENEMYTILES)?4:2);
1203 16109996 }
1204
1205 37821661 ox = nx;
1206 37821661 oy = ny;
1207
1208 // Maybe they fell off the bottom in sideview, or were moved by a script.
1209
1210 //Check offscreen settings. I wrote it this way for clarity and to simplify testing. -Z
1211
2/2
✓ Branch 0 taken 1829 times.
✓ Branch 1 taken 37819832 times.
37821661 if ( immortal )
1212 {
1213 //skip, as it can go out of bounds, from immortality
1214 1829 }
1215
2/6
✓ Branch 0 taken 37819832 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 37819832 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
37819832 else if ( (moveflags & move_ignore_screenedge) || (( (get_qr(qr_OUTOFBOUNDSENEMIES)) != bool(editorflags&ENEMY_FLAG11) ) && !NEWOUTOFBOUNDS(x,y,z+fakez)) )
1216 {
1217 //skip, it can go out of bounds, from a quest rule, or from the enemy editor (but not both!)
1218 }
1219
9/10
✓ Branch 0 taken 37423739 times.
✓ Branch 1 taken 396093 times.
✓ Branch 2 taken 37818827 times.
✓ Branch 3 taken 1005 times.
✓ Branch 4 taken 37788803 times.
✓ Branch 5 taken 30024 times.
✓ Branch 6 taken 37788803 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 51 times.
✓ Branch 9 taken 37788752 times.
37819832 else if ( (OUTOFBOUNDS) )
1220 {
1221 31080 hp=-1000; //kill it, as it is not immortal, and no quest bit or rule is enabled
1222 31080 }
1223 //fall down
1224
6/6
✓ Branch 0 taken 27134533 times.
✓ Branch 1 taken 10687128 times.
✓ Branch 2 taken 10419698 times.
✓ Branch 3 taken 27401963 times.
✓ Branch 4 taken 506382 times.
✓ Branch 5 taken 9913316 times.
37821661 if((enemycanfall(id) || (moveflags & move_obeys_grav) )&& fading != fade_flicker && clk>=0)
1225 {
1226
2/2
✓ Branch 0 taken 303574 times.
✓ Branch 1 taken 9609742 times.
9913316 if(isSideViewGravity())
1227 {
1228
1/2
✓ Branch 0 taken 303574 times.
✗ Branch 1 not taken.
303574 if(get_qr(qr_OLD_SIDEVIEW_LANDING_CODE))
1229 {
1230
2/2
✓ Branch 0 taken 176339 times.
✓ Branch 1 taken 127235 times.
303574 if(!isOnSideviewPlatform())
1231 {
1232 127235 bool willHitSVPlatform = false;
1233
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 127235 times.
127235 int32_t usewid = (SIZEflags&OVERRIDE_HIT_WIDTH)?hit_width:16;
1234
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 127235 times.
127235 int32_t usehei = (SIZEflags&OVERRIDE_HIT_HEIGHT)?hit_height:16;
1235
2/2
✓ Branch 0 taken 127235 times.
✓ Branch 1 taken 127235 times.
254470 for(int32_t nx = x+4; nx < x+usewid; nx+=16)
1236 {
1237
5/8
✓ Branch 0 taken 23361 times.
✓ Branch 1 taken 103874 times.
✓ Branch 2 taken 23361 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 23361 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 127235 times.
✗ Branch 7 not taken.
127235 if(fall > 0 && !IGNORE_SIDEVIEW_PLATFORMS && checkSVLadderPlatform(x+4,y+(fall/100)+usehei-1) && (((int32_t(y)+(int32_t(fall)/100)+usehei-1)&0xF0)!=((int32_t(y)+usehei-1)&0xF0)))
1238 {
1239 willHitSVPlatform = true;
1240 break;
1241 }
1242 127235 }
1243
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 127235 times.
127235 if(willHitSVPlatform)
1244 {
1245 y+=fall/100;
1246 //y-=int32_t(y)%16; //Fix to top of SV Ladder
1247 do_fix(y, 16); //Fix to top of SV Ladder
1248 fall = 0;
1249 }
1250 else
1251 {
1252 127235 y+=fall/100;
1253
2/2
✓ Branch 0 taken 17808 times.
✓ Branch 1 taken 109427 times.
127235 if(fall <= (int32_t)zinit.terminalv)
1254 109427 fall += (zinit.gravity/100);
1255 }
1256 127235 }
1257 else
1258 {
1259
2/2
✓ Branch 0 taken 267 times.
✓ Branch 1 taken 176072 times.
176339 if(fall!=0) // Only fix pos once
1260 {
1261 //y-=(int32_t)y%8; // Fix position
1262 267 do_fix(y, 8); //Fix position
1263 267 }
1264
1265 176339 fall = 0;
1266 }
1267 303574 }
1268 else
1269 {
1270 if(isOnSideviewPlatform())
1271 fall = 0;
1272 else
1273 {
1274 zfix fall_amnt = fall/100;
1275 bool hit = false;
1276 while(fall_amnt >= 1)
1277 {
1278 --fall_amnt;
1279 ++y;
1280 if(isOnSideviewPlatform())
1281 {
1282 y = y.getInt();
1283 fall_amnt = 0;
1284 hit = true;
1285 break;
1286 }
1287 }
1288 if(fall_amnt > 0)
1289 y += fall_amnt;
1290 if(fall_amnt < 0)
1291 {
1292 if(!movexy(0,fall_amnt,spw_none,false,!get_qr(qr_BROKEN_SIDEVIEW_SPRITE_JUMP)))
1293 hit = true;
1294 }
1295 if(hit)
1296 fall = 0;
1297 else if(fall <= (int32_t)zinit.terminalv)
1298 fall += (zinit.gravity/100);
1299 }
1300 }
1301 303574 }
1302 else
1303 {
1304
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9609742 times.
9609742 if (!(moveflags & move_no_fake_z))
1305 {
1306
2/2
✓ Branch 0 taken 5056840 times.
✓ Branch 1 taken 4552902 times.
9609742 if(fakefall!=0)
1307 4552902 fakez-=(fakefall/100);
1308
1309
2/2
✓ Branch 0 taken 4552902 times.
✓ Branch 1 taken 5056840 times.
9609742 if(fakez<0)
1310 4552902 fakez = fakefall = 0;
1311
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5056840 times.
5056840 else if(fakefall <= (int32_t)zinit.terminalv)
1312 5056840 fakefall += (zinit.gravity/100);
1313
1314
5/6
✓ Branch 0 taken 9609742 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5056840 times.
✓ Branch 3 taken 4552902 times.
✓ Branch 4 taken 4567130 times.
✓ Branch 5 taken 489710 times.
9609742 if (fakez<=0 && fakefall > 0 && !get_qr(qr_FLUCTUATING_ENEMY_JUMP)) fakefall = 0;
1315 9609742 }
1316
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9609742 times.
9609742 if (!(moveflags & move_no_real_z))
1317 {
1318
2/2
✓ Branch 0 taken 5477877 times.
✓ Branch 1 taken 4131865 times.
9609742 if(fall!=0)
1319 4131865 z-=(fall/100);
1320
1321
2/2
✓ Branch 0 taken 4118583 times.
✓ Branch 1 taken 5491159 times.
9609742 if(z<0)
1322 4118583 z = fall = 0;
1323
2/2
✓ Branch 0 taken 9167 times.
✓ Branch 1 taken 5481992 times.
5491159 else if(fall <= (int32_t)zinit.terminalv)
1324 5481992 fall += (zinit.gravity/100);
1325
1326
6/6
✓ Branch 0 taken 9568838 times.
✓ Branch 1 taken 40904 times.
✓ Branch 2 taken 5450255 times.
✓ Branch 3 taken 4118583 times.
✓ Branch 4 taken 4962352 times.
✓ Branch 5 taken 487903 times.
9609742 if (z<=0 && fall > 0 && !get_qr(qr_FLUCTUATING_ENEMY_JUMP)) fall = 0;
1327 9609742 }
1328
1329 }
1330 9913316 }
1331
4/4
✓ Branch 0 taken 37425568 times.
✓ Branch 1 taken 396093 times.
✓ Branch 2 taken 9193428 times.
✓ Branch 3 taken 28232140 times.
37821661 if(!isSideViewGravity() && (moveflags & move_can_pitfall))
1332 {
1333
8/10
✓ Branch 0 taken 9167028 times.
✓ Branch 1 taken 26400 times.
✓ Branch 2 taken 9127370 times.
✓ Branch 3 taken 39658 times.
✓ Branch 4 taken 9127370 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 9167028 times.
✓ Branch 8 taken 9127370 times.
✓ Branch 9 taken 9127370 times.
9193428 if(can_pitfall() && ((z <= 0 && fakez <= 0 && !isflier(id)) || (isflier(id) && (stunclk))) && !superman)
1334 {
1335 9127370 fallCombo = check_pits();
1336 9127370 }
1337 27448168 }
1338
4/4
✓ Branch 0 taken 37425568 times.
✓ Branch 1 taken 18650833 times.
✓ Branch 2 taken 146615 times.
✓ Branch 3 taken 37278953 times.
56076401 if(!isSideViewGravity() && (moveflags & move_can_waterdrown))
1339 {
1340
8/10
✓ Branch 0 taken 142669 times.
✓ Branch 1 taken 3946 times.
✓ Branch 2 taken 141616 times.
✓ Branch 3 taken 1053 times.
✓ Branch 4 taken 141616 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 142669 times.
✓ Branch 8 taken 141616 times.
✓ Branch 9 taken 141616 times.
146615 if(can_pitfall() && ((z <= 0 && fakez <= 0 && !isflier(id)) || (isflier(id) && (stunclk))) && !superman)
1341 {
1342 141616 drownCombo = check_water();
1343 141616 }
1344 429847 }
1345
1346 56359633 runKnockback(); //scripted knockback handling
1347
1348 // clk is incremented here
1349
2/2
✓ Branch 0 taken 54055093 times.
✓ Branch 1 taken 2304540 times.
56359633 if(++clk >= frate)
1350 2304540 clk=0;
1351
1352 // hit and death handling
1353
2/2
✓ Branch 0 taken 1240301 times.
✓ Branch 1 taken 55119332 times.
56359633 if(hclk>0)
1354 1240301 --hclk;
1355
1356
2/2
✓ Branch 0 taken 676239 times.
✓ Branch 1 taken 55683394 times.
56359633 if(stunclk>0)
1357 676239 --stunclk;
1358
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 56359633 times.
56359633 if ( frozenclock > 0 )
1359 --frozenclock;
1360
1361
5/6
✓ Branch 0 taken 13488 times.
✓ Branch 1 taken 56346145 times.
✓ Branch 2 taken 106 times.
✓ Branch 3 taken 13382 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 106 times.
56359633 if(ceiling && z <= 0 && fakez <= 0)
1362 106 ceiling = false;
1363
1364 56359633 try_death();
1365
1366 56359633 scored=false;
1367
1368 56359633 ++c_clk;
1369
1370 //Run its script
1371
2/2
✓ Branch 0 taken 18562789 times.
✓ Branch 1 taken 37796844 times.
56359633 if (!didScriptThisFrame)
1372 {
1373
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 37796844 times.
37796844 if (runscript_do_earlyret(run_script(MODE_NORMAL)))
1374 {
1375 return 0; //Avoid NULLPO if this object deleted itself
1376 }
1377 37796844 }
1378
1379 // returns true when enemy is defeated
1380 56359633 return Dead(index);
1381 56362187 }
1382
1383 38576082 bool enemy::setSolid(bool set)
1384 {
1385
1/2
✓ Branch 0 taken 38576082 times.
✗ Branch 1 not taken.
38576082 bool actual = set && !isSubmerged();
1386 38576082 bool ret = solid_object::setSolid(actual);
1387 38576082 solid = set;
1388 38576082 return ret;
1389 }
1390 void enemy::doContactDamage(int32_t hdir)
1391 {
1392 Hero.hithero(guys.find(this), hdir);
1393 }
1394
1395 22405 void enemy::solid_push(solid_object *obj)
1396 {
1397
1/2
✓ Branch 0 taken 22405 times.
✗ Branch 1 not taken.
22405 if(obj == this) return; //can't push self
1398
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22405 times.
22405 if(moveflags&move_not_pushable) return; //not pushable
1399 22405 zfix dx, dy;
1400 22405 int32_t hdir = -1;
1401 22405 solid_push_int(obj,dx,dy,hdir,true);
1402
1403
4/4
✓ Branch 0 taken 22292 times.
✓ Branch 1 taken 113 times.
✓ Branch 2 taken 150 times.
✓ Branch 3 taken 22142 times.
22405 if(!dx && !dy) return;
1404
1405 263 bool t = obj->getTempNonsolid();
1406 263 obj->setTempNonsolid(true);
1407
1408 263 int32_t ydir = dy > 0 ? down : up;
1409 263 int32_t xdir = dx > 0 ? right : left;
1410
1411 263 auto special = isflier(id) ? spw_floater : spw_none;
1412
2/2
✓ Branch 0 taken 256 times.
✓ Branch 1 taken 7 times.
263 if(!movexy(dx,dy,special,true,true))
1413 {
1414 //Crushed?
1415 7 }
1416
1417 263 obj->setTempNonsolid(t);
1418 22405 }
1419 22405 bool enemy::is_unpushable() const
1420 {
1421 22405 return isSubmerged();
1422 }
1423 22087 bool enemy::sideview_mode() const
1424 {
1425
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 22087 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
22087 return isSideViewGravity() && (moveflags&move_obeys_grav) && !(moveflags&move_not_pushable);
1426 }
1427
1428 3234 bool enemy::m_walkflag_old(int32_t dx,int32_t dy,int32_t special, int32_t x, int32_t y)
1429 {
1430 3234 int32_t yg = (special==spw_floater)?8:0;
1431 3234 int32_t nb = get_qr(qr_NOBORDER) ? 16 : 0;
1432
1433
8/10
✓ Branch 0 taken 2364 times.
✓ Branch 1 taken 870 times.
✓ Branch 2 taken 814 times.
✓ Branch 3 taken 56 times.
✓ Branch 4 taken 870 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 870 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 2368 times.
✓ Branch 9 taken 3238 times.
3234 if(dx<16-nb || dy<zc_max(16-yg-nb,0) || dx>=240+nb || dy>=160+nb)
1434 4732 return true;
1435
1436 3238 bool isInDungeon = isdungeon();
1437
3/4
✓ Branch 0 taken 262 times.
✓ Branch 1 taken 2976 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 262 times.
3238 if(isInDungeon || special==spw_wizzrobe)
1438 {
1439
7/8
✓ Branch 0 taken 601 times.
✓ Branch 1 taken 2375 times.
✓ Branch 2 taken 595 times.
✓ Branch 3 taken 8 times.
✓ Branch 4 taken 604 times.
✓ Branch 5 taken 1779 times.
✓ Branch 6 taken 604 times.
✗ Branch 7 not taken.
2976 if((x>=32 && dy<32-yg) || (y>-1000 && y<=144 && dy>=144))
1440 1199 return true;
1441
1442
7/8
✓ Branch 0 taken 592 times.
✓ Branch 1 taken 1187 times.
✓ Branch 2 taken 595 times.
✓ Branch 3 taken 3 times.
✓ Branch 4 taken 595 times.
✓ Branch 5 taken 595 times.
✓ Branch 6 taken 595 times.
✗ Branch 7 not taken.
1779 if((x>=32 && dx<32) || (x>-1000 && x<224 && dx>=224))
1443
0/2
✗ Branch 0 not taken.
✗ Branch 1 not taken.
1190 if(special!=spw_door) // walk in door way
1444 return true;
1445 595 }
1446
1447
3/4
✓ Branch 0 taken 62 times.
✓ Branch 1 taken 795 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 62 times.
857 if(!(moveflags & move_can_pitwalk) && !(moveflags & move_can_pitfall)) //Don't walk into pits (knockback doesn't call this func)
1448 {
1449
2/4
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 62 times.
124 if(ispitfall(dx,dy) || ispitfall(dx+8,dy)
1450
2/4
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 62 times.
✗ Branch 3 not taken.
62 || ispitfall(dx,dy+8) || ispitfall(dx+8,dy+8))
1451 return true;
1452 62 }
1453
1454
1/4
✓ Branch 0 taken 857 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
857 switch(special)
1455 {
1456 case spw_clipbottomright:
1457 if(dy>=128 || dx>=208) return true;
1458 break;
1459 case spw_clipright:
1460 break; //if(x>=208) return true; break;
1461
1462 case spw_wizzrobe: // fall through
1463 case spw_floater: // Special case for fliers and wizzrobes - hack!
1464 {
1465
2/2
✓ Branch 0 taken 262 times.
✓ Branch 1 taken 595 times.
857 if(isInDungeon)
1466 {
1467
2/4
✓ Branch 0 taken 595 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 595 times.
595 if(dy < 32-yg || dy >= 144) return true;
1468
2/4
✓ Branch 0 taken 595 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 595 times.
595 if(dx < 32 || dx >= 224) return true;
1469 595 }
1470 857 return false;
1471 }
1472 }
1473
1474 dx&=(special==spw_halfstep)?(~7):(~15);
1475 dy&=(special==spw_halfstep || isSideViewGravity())?(~7):(~15);
1476
1477 if(special==spw_water)
1478 return (water_walkflag(dx,dy+8,1) || water_walkflag(dx+8,dy+8,1));
1479
1480 return _walkflag(dx,dy+8,1) || _walkflag(dx+8,dy+8,1) ||
1481 groundblocked(dx,dy+8) || groundblocked(dx+8,dy+8);
1482 870 }
1483
1484 6575 bool enemy::m_walkflag_simple(int32_t dx,int32_t dy)
1485 {
1486 6575 bool kb = false;
1487 6575 int32_t nb = get_qr(qr_NOBORDER) ? 16 : 0;
1488
1489
5/10
✗ Branch 0 not taken.
✓ Branch 1 taken 6575 times.
✓ Branch 2 taken 6575 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 6575 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 6575 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 6575 times.
6575 if(dx<16-nb || dy<zc_max(16-nb,0) || dx>=240+nb || dy>=160+nb)
1490 return true;
1491
1492
2/2
✓ Branch 0 taken 5062 times.
✓ Branch 1 taken 1513 times.
6575 if(isdungeon())
1493 {
1494
2/4
✓ Branch 0 taken 1513 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1513 times.
1513 if((dy<32) || (dy>=144))
1495 return true;
1496
1497
2/4
✓ Branch 0 taken 1513 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1513 times.
1513 if((dx<32) || (dx>=224))
1498 return true;
1499 1513 }
1500
1501
2/4
✓ Branch 0 taken 6575 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 6575 times.
6575 if(!(moveflags & move_can_pitwalk) && (!(moveflags & move_can_pitfall))) //Don't walk into pits, unless being knocked back
1502 {
1503
2/4
✓ Branch 0 taken 6575 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 6575 times.
13150 if(ispitfall(dx,dy) || ispitfall(dx+8,dy)
1504
2/4
✓ Branch 0 taken 6575 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6575 times.
✗ Branch 3 not taken.
6575 || ispitfall(dx,dy+8) || ispitfall(dx+8,dy+8))
1505 return true;
1506 6575 }
1507
1508
2/2
✓ Branch 0 taken 6545 times.
✓ Branch 1 taken 30 times.
6575 if(get_qr(qr_ENEMY_BROKEN_TOP_HALF_SOLIDITY))
1509 {
1510
3/4
✓ Branch 0 taken 2657 times.
✓ Branch 1 taken 3888 times.
✓ Branch 2 taken 2657 times.
✗ Branch 3 not taken.
9202 return _walkflag(dx,dy+8,1) || _walkflag(dx+8,dy+8,1) ||
1511
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2657 times.
2657 groundblocked(dx,dy+8,kb) || groundblocked(dx+8,dy+8,kb);
1512 }
1513 else
1514 {
1515
2/4
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 30 times.
✗ Branch 3 not taken.
60 return _walkflag(dx,dy,1) || _walkflag(dx+8,dy,1) ||
1516
2/4
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 30 times.
✗ Branch 3 not taken.
30 _walkflag(dx,dy+8,1) || _walkflag(dx+8,dy+8,1) ||
1517
2/4
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 30 times.
✗ Branch 3 not taken.
30 groundblocked(dx,dy,kb) || groundblocked(dx+8,dy,kb) ||
1518
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
30 groundblocked(dx,dy+8,kb) || groundblocked(dx+8,dy+8,kb);
1519 }
1520 6575 }
1521
1522 32455575 bool enemy::m_walkflag(int32_t dx,int32_t dy,int32_t special, int32_t dir, int32_t input_x, int32_t input_y, bool kb)
1523 {
1524
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 32455575 times.
32455575 if(moveflags & move_new_movement)
1525 return scr_walkflag(dx,dy,special,dir,input_x,input_y,kb);
1526 32455575 int32_t yg = (special==spw_floater)?8:0;
1527 32455575 int32_t nb = get_qr(qr_NOBORDER) ? 16 : 0;
1528
2/2
✓ Branch 0 taken 3703963 times.
✓ Branch 1 taken 28751612 times.
32455575 switch(dir)
1529 {
1530 case l_down:
1531 case r_down:
1532 case down:
1533 case 11: //r_down
1534 case 12: //down
1535 case 13: //l_down
1536 {
1537
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3703963 times.
3703963 if ( ((unsigned)(id&0xFFF)) < MAXGUYS )
1538 {
1539
3/4
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 3703955 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 8 times.
3703963 if ( SIZEflags&OVERRIDE_HIT_HEIGHT && !isflier(id) )
1540 {
1541 //Small enemies are treated as 16x16, for the purposes of m_walkflag!
1542
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 dy += zc_max(hit_height-16,0);
1543 8 }
1544 3703963 }
1545 3703963 break;
1546 }
1547 }
1548
2/2
✓ Branch 0 taken 3704751 times.
✓ Branch 1 taken 28750824 times.
32455575 switch(dir)
1549 {
1550 case r_up:
1551 case r_down:
1552 case right:
1553 case 9: //r_up
1554 case 10: //right
1555 case 11: //r_down
1556 {
1557
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3704751 times.
3704751 if ( ((unsigned)(id&0xFFF)) < MAXGUYS )
1558 {
1559
3/4
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 3704748 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3 times.
3704751 if ( SIZEflags&OVERRIDE_HIT_WIDTH && !isflier(id) )
1560 {
1561 //Small enemies are treated as 16x16, for the purposes of m_walkflag!
1562
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 dx += zc_max(hit_width-16,0);
1563 3 }
1564 3704751 }
1565 3704751 break;
1566 }
1567 }
1568 //Z_eventlog("Checking x,y %d,%d\n",dx,dy);
1569
1570
10/10
✓ Branch 0 taken 22401614 times.
✓ Branch 1 taken 10053961 times.
✓ Branch 2 taken 8752343 times.
✓ Branch 3 taken 1301618 times.
✓ Branch 4 taken 10016882 times.
✓ Branch 5 taken 37079 times.
✓ Branch 6 taken 9993755 times.
✓ Branch 7 taken 23127 times.
✓ Branch 8 taken 22454486 times.
✓ Branch 9 taken 32448241 times.
32455575 if(dx<16-nb || dy<zc_max(16-yg-nb,0) || dx>=240+nb || dy>=160+nb)
1571 44916306 return true;
1572
1573 32448241 bool isInDungeon = isdungeon();
1574
4/4
✓ Branch 0 taken 3927110 times.
✓ Branch 1 taken 28521131 times.
✓ Branch 2 taken 11756 times.
✓ Branch 3 taken 3915354 times.
32448241 if(isInDungeon || special==spw_wizzrobe)
1575 {
1576
8/8
✓ Branch 0 taken 5892066 times.
✓ Branch 1 taken 22640821 times.
✓ Branch 2 taken 5667599 times.
✓ Branch 3 taken 224467 times.
✓ Branch 4 taken 5820182 times.
✓ Branch 5 taken 17045106 times.
✓ Branch 6 taken 5819995 times.
✓ Branch 7 taken 187 times.
28532887 if((input_x>=32 && dy<32-yg) || (input_y>-1000 && input_y<=144 && dy>=144))
1577 11487594 return true;
1578
1579
8/8
✓ Branch 0 taken 5739703 times.
✓ Branch 1 taken 11305590 times.
✓ Branch 2 taken 5573250 times.
✓ Branch 3 taken 166453 times.
✓ Branch 4 taken 5688164 times.
✓ Branch 5 taken 5783879 times.
✓ Branch 6 taken 5687210 times.
✓ Branch 7 taken 954 times.
17045293 if((input_x>=32 && dx<32) || (input_x>-1000 && input_x<224 && dx>=224))
1580
2/2
✓ Branch 0 taken 113866 times.
✓ Branch 1 taken 94 times.
11260460 if(special!=spw_door) // walk in door way
1581 113866 return true;
1582 5784927 }
1583
1584
6/6
✓ Branch 0 taken 3100315 times.
✓ Branch 1 taken 6599966 times.
✓ Branch 2 taken 750003 times.
✓ Branch 3 taken 2350312 times.
✓ Branch 4 taken 51230 times.
✓ Branch 5 taken 698773 times.
9700281 if(!(moveflags & move_can_pitwalk) && (!(moveflags & move_can_pitfall) || !kb)) //Don't walk into pits, unless being knocked back
1585 {
1586
4/4
✓ Branch 0 taken 3042668 times.
✓ Branch 1 taken 6417 times.
✓ Branch 2 taken 50 times.
✓ Branch 3 taken 3041716 times.
6090851 if(ispitfall(dx,dy) || ispitfall(dx+8,dy)
1587
4/4
✓ Branch 0 taken 3042485 times.
✓ Branch 1 taken 183 times.
✓ Branch 2 taken 3041766 times.
✓ Branch 3 taken 719 times.
3042668 || ispitfall(dx,dy+8) || ispitfall(dx+8,dy+8))
1588 7369 return true;
1589 3041716 }
1590
1591
4/4
✓ Branch 0 taken 7508153 times.
✓ Branch 1 taken 2178505 times.
✓ Branch 2 taken 973 times.
✓ Branch 3 taken 5281 times.
9692912 switch(special)
1592 {
1593 case spw_clipbottomright:
1594
4/4
✓ Branch 0 taken 786 times.
✓ Branch 1 taken 187 times.
✓ Branch 2 taken 79 times.
✓ Branch 3 taken 707 times.
973 if(dy>=128 || dx>=208) return true;
1595 707 break;
1596 case spw_clipright:
1597 5281 break; //if(input_x>=208) return true; break;
1598
1599 case spw_wizzrobe: // fall through
1600 case spw_floater: // Special case for fliers and wizzrobes - hack!
1601 {
1602
2/2
✓ Branch 0 taken 2866474 times.
✓ Branch 1 taken 4641679 times.
7508153 if(isInDungeon)
1603 {
1604
3/4
✓ Branch 0 taken 4641667 times.
✓ Branch 1 taken 12 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4641667 times.
4641679 if(dy < 32-yg || dy >= 144) return true;
1605
4/4
✓ Branch 0 taken 4639555 times.
✓ Branch 1 taken 2112 times.
✓ Branch 2 taken 16 times.
✓ Branch 3 taken 4639539 times.
4641667 if(dx < 32 || dx >= 224) return true;
1606 4639539 }
1607 7506013 return false;
1608 }
1609 }
1610
1611 2184493 dx&=(special==spw_halfstep)?(~7):(~15);
1612
2/2
✓ Branch 0 taken 486587 times.
✓ Branch 1 taken 1697906 times.
2184493 dy&=(special==spw_halfstep || isSideViewGravity())?(~7):(~15);
1613
1614
2/2
✓ Branch 0 taken 414391 times.
✓ Branch 1 taken 1770102 times.
2184493 if(special==spw_water)
1615
2/2
✓ Branch 0 taken 16741 times.
✓ Branch 1 taken 397650 times.
414391 return (water_walkflag(dx,dy+8,1) || water_walkflag(dx+8,dy+8,1));
1616
1617
2/2
✓ Branch 0 taken 1711234 times.
✓ Branch 1 taken 58868 times.
1770102 if(get_qr(qr_ENEMY_BROKEN_TOP_HALF_SOLIDITY))
1618 {
1619
4/4
✓ Branch 0 taken 1227843 times.
✓ Branch 1 taken 483391 times.
✓ Branch 2 taken 1217806 times.
✓ Branch 3 taken 10037 times.
2929040 return _walkflag(dx,dy+8,1) || _walkflag(dx+8,dy+8,1) ||
1620
2/2
✓ Branch 0 taken 14580 times.
✓ Branch 1 taken 1203226 times.
1217806 groundblocked(dx,dy+8,kb) || groundblocked(dx+8,dy+8,kb);
1621 }
1622 else
1623 {
1624
4/4
✓ Branch 0 taken 42375 times.
✓ Branch 1 taken 16493 times.
✓ Branch 2 taken 42111 times.
✓ Branch 3 taken 264 times.
100979 return _walkflag(dx,dy,1) || _walkflag(dx+8,dy,1) ||
1625
3/4
✓ Branch 0 taken 41748 times.
✓ Branch 1 taken 363 times.
✓ Branch 2 taken 41748 times.
✗ Branch 3 not taken.
42111 _walkflag(dx,dy+8,1) || _walkflag(dx+8,dy+8,1) ||
1626
4/4
✓ Branch 0 taken 36513 times.
✓ Branch 1 taken 5235 times.
✓ Branch 2 taken 36498 times.
✓ Branch 3 taken 15 times.
41748 groundblocked(dx,dy,kb) || groundblocked(dx+8,dy,kb) ||
1627
2/2
✓ Branch 0 taken 36195 times.
✓ Branch 1 taken 303 times.
36498 groundblocked(dx,dy+8,kb) || groundblocked(dx+8,dy+8,kb);
1628 }
1629 10079621 }
1630
1631 383430 bool enemy::isOnSideviewPlatform()
1632 {
1633
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 383430 times.
383430 int32_t usewid = (SIZEflags&OVERRIDE_HIT_WIDTH) ? hit_width : 16;
1634
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 383430 times.
383430 int32_t usehei = (SIZEflags&OVERRIDE_HIT_HEIGHT) ? hit_height : 16;
1635
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 383430 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
383430 if(!get_qr(qr_BROKEN_SIDEVIEW_SPRITE_JUMP)&&fall<0)
1636 return false;
1637
5/6
✓ Branch 0 taken 10306 times.
✓ Branch 1 taken 373124 times.
✓ Branch 2 taken 211 times.
✓ Branch 3 taken 10095 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 211 times.
383430 if(y + usehei >= 176 && currscr>=0x70 && !(tmpscr->flags2&wfDOWN)) return true; //Bottom of the map
1638
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 383219 times.
383219 if(check_slope(x, y+1, usewid, usehei)) return true;
1639
2/2
✓ Branch 0 taken 383219 times.
✓ Branch 1 taken 168001 times.
551220 for(int32_t nx = x + 4; nx <= x + usewid - 4; nx+=16)
1640 {
1641
2/2
✓ Branch 0 taken 168001 times.
✓ Branch 1 taken 215218 times.
383219 if(_walkflag(nx,y+usehei,1)) return true;
1642
3/4
✓ Branch 0 taken 168001 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 120644 times.
✓ Branch 3 taken 47357 times.
168001 if(IGNORE_SIDEVIEW_PLATFORMS || ((int32_t(y)+usehei)%16)!=0) continue;
1643
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 47357 times.
47357 if(checkSVLadderPlatform(nx,y+usehei)) return true;
1644 47357 }
1645 168001 return false;
1646 383430 }
1647
1648 // Stops playing the given sound only if there are no enemies left to play it
1649 765900 void enemy::stop_bgsfx(int32_t index)
1650 {
1651
2/2
✓ Branch 0 taken 750790 times.
✓ Branch 1 taken 15110 times.
765900 if(bgsfx<=0)
1652 750790 return;
1653
1654 // Look for other enemies with the same bgsfx
1655
2/2
✓ Branch 0 taken 52994 times.
✓ Branch 1 taken 8806 times.
61800 for(int32_t i=0; i<guys.Count(); i++)
1656 {
1657
4/4
✓ Branch 0 taken 41902 times.
✓ Branch 1 taken 11092 times.
✓ Branch 2 taken 6304 times.
✓ Branch 3 taken 35598 times.
52994 if(i!=index && ((enemy*)guys.spr(i))->bgsfx==bgsfx)
1658 6304 return;
1659 46690 }
1660
1661 8806 stop_sfx(bgsfx);
1662 765900 }
1663
1664
1665 // to allow for different sfx on defeating enemy
1666 40243 void enemy::death_sfx()
1667 {
1668
2/2
✓ Branch 0 taken 39959 times.
✓ Branch 1 taken 284 times.
40243 if(deadsfx > 0) sfx(deadsfx,pan(int32_t(x)));
1669 40243 }
1670
1671 void enemy::move(zfix dx,zfix dy)
1672 {
1673 /*if(FFCore.getQuestHeaderInfo(vZelda) >= 0x255 && FFCore.getQuestHeaderInfo(vBuild) >= 50 )
1674 {
1675 switch(family)
1676 {
1677 case eeFIRE:
1678 case eeOTHER:
1679 return;
1680 default: break;
1681 }
1682 if(family >= eeSCRIPT01 && family <= eeFFRIENDLY10 ) return;
1683 }
1684 */
1685 if(!watch && (!(isSideViewGravity()) || isOnSideviewPlatform() || !(moveflags & move_obeys_grav) || !enemycanfall(id)))
1686 {
1687 x+=dx;
1688 y+=dy;
1689 }
1690 }
1691
1692 18325627 void enemy::move(zfix s)
1693 {
1694 /*if(FFCore.getQuestHeaderInfo(vZelda) >= 0x255 && FFCore.getQuestHeaderInfo(vBuild) >= 50 )
1695 {
1696 switch(family)
1697 {
1698 case eeFIRE:
1699 case eeOTHER:
1700 return;
1701 default: break;
1702 }
1703 if(family >= eeSCRIPT01 && family <= eeFFRIENDLY10 ) return;
1704 }*/
1705
9/10
✓ Branch 0 taken 18325588 times.
✓ Branch 1 taken 39 times.
✓ Branch 2 taken 79762 times.
✓ Branch 3 taken 18245826 times.
✓ Branch 4 taken 40724 times.
✓ Branch 5 taken 39038 times.
✓ Branch 6 taken 855 times.
✓ Branch 7 taken 39869 times.
✓ Branch 8 taken 855 times.
✗ Branch 9 not taken.
18325627 if(!watch && (!(isSideViewGravity()) || isOnSideviewPlatform() || !enemycanfall(id) || !(moveflags & move_obeys_grav)))
1706 {
1707 18324733 sprite::move(s);
1708 18324733 }
1709 18325627 }
1710
1711 43678 void enemy::leave_item()
1712 {
1713 43678 int32_t drop_item = select_dropitem(item_set, x, y);
1714 43678 int32_t thedropset = item_set;
1715
1716 43678 std::vector<int32_t> &ev = FFCore.eventData;
1717 43678 ev.clear();
1718 43678 ev.push_back(getUID());
1719 43678 ev.push_back(drop_item*10000);
1720 43678 ev.push_back(thedropset*10000);
1721
1722 43678 throwGenScriptEvent(GENSCR_EVENT_ENEMY_DROP_ITEM_1);
1723 43678 drop_item = vbound(ev[1] / 10000,-2,255);
1724 43678 thedropset = ev[2] / 10000;
1725 43678 ev.clear();
1726
1/2
✓ Branch 0 taken 43678 times.
✗ Branch 1 not taken.
43678 if(drop_item == -2)
1727 {
1728 drop_item = select_dropitem(thedropset,x,y);
1729 }
1730
1731
6/6
✓ Branch 0 taken 16429 times.
✓ Branch 1 taken 27249 times.
✓ Branch 2 taken 917 times.
✓ Branch 3 taken 15512 times.
✓ Branch 4 taken 169 times.
✓ Branch 5 taken 748 times.
43678 if(drop_item>=0&&((itemsbuf[drop_item].family!=itype_fairy)||!m_walkflag(x,y,0,dir)))
1732 {
1733 item* itm;
1734
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16260 times.
16260 if (get_qr(qr_ENEMY_DROPS_USE_HITOFFSETS))
1735 {
1736 itm = (new item(x+hxofs+(hit_width/2)-8,y+hyofs+(hit_height/2)-8,(zfix)0,drop_item,ipBIGRANGE+ipTIMER,0));
1737 }
1738 else
1739 {
1740
8/14
✓ Branch 0 taken 1629 times.
✓ Branch 1 taken 14631 times.
✓ Branch 2 taken 1629 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1629 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1629 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1629 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 1629 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 1629 times.
✗ Branch 13 not taken.
16260 if(extend >= 3) itm = (new item(x+(txsz-1)*8,y+(tysz-1)*8,(zfix)0,drop_item,ipBIGRANGE+ipTIMER,0));
1741
4/8
✓ Branch 0 taken 14631 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 14631 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 14631 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 14631 times.
✗ Branch 7 not taken.
14631 else itm = (new item(x,y,(zfix)0,drop_item,ipBIGRANGE+ipTIMER,0));
1742 }
1743 16260 itm->from_dropset = thedropset;
1744 16260 items.add(itm);
1745
1746 16260 ev.push_back(getUID());
1747 16260 ev.push_back(itm->getUID());
1748
1749 16260 throwGenScriptEvent(GENSCR_EVENT_ENEMY_DROP_ITEM_2);
1750 16260 ev.clear();
1751 16260 }
1752 43678 }
1753
1754 // auomatically kill off enemy (for rooms with ringleaders)
1755 397 void enemy::kickbucket()
1756 {
1757
3/4
✓ Branch 0 taken 365 times.
✓ Branch 1 taken 32 times.
✓ Branch 2 taken 365 times.
✗ Branch 3 not taken.
397 if(!superman && !(flags&guy_ignore_kill_all))
1758 365 hp=-1000; // don't call death_sfx()
1759 397 }
1760
1761 21250 bool enemy::isSubmerged() const
1762 {
1763 21250 return submerged;
1764 //!TODO SOLIDPUSH more things like teleporting wizzrobes
1765 }
1766
1767 20952 void enemy::FireBreath(bool seekhero)
1768 {
1769
1/2
✓ Branch 0 taken 20952 times.
✗ Branch 1 not taken.
20952 if(wpn==wNone)
1770 return;
1771
1772
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 20952 times.
20952 if(wpn==ewFireTrail)
1773 {
1774 dmisc1 = e1tEACHTILE;
1775 FireWeapon();
1776 return;
1777 }
1778
1779 20952 float fire_angle=0.0;
1780 20952 int32_t wx=0, wy=0, wdir=dir;
1781
1782
2/2
✓ Branch 0 taken 5081 times.
✓ Branch 1 taken 15871 times.
20952 if(!seekhero)
1783 {
1784
4/5
✓ Branch 0 taken 3297 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3079 times.
✓ Branch 3 taken 5287 times.
✓ Branch 4 taken 4208 times.
15871 switch(dir)
1785 {
1786 case down:
1787 3079 fire_angle=PI*(int64_t(zc_oldrand()%20)+10)/40;
1788 3079 wx=x;
1789 3079 wy=y+8;
1790 3079 break;
1791
1792 case -1:
1793 case up:
1794 3297 fire_angle=PI*(int64_t(zc_oldrand()%20)+50)/40;
1795 3297 wx=x;
1796 3297 wy=y-8;
1797 3297 break;
1798
1799 case left:
1800 5287 fire_angle=PI*(int64_t(zc_oldrand()%20)+30)/40;
1801 5287 wx=x-8;
1802 5287 wy=y;
1803 5287 break;
1804
1805 case right:
1806 4208 fire_angle=PI*(int64_t(zc_oldrand()%20)+70)/40;
1807 4208 wx=x+8;
1808 4208 wy=y;
1809 4208 break;
1810 }
1811
1812
3/4
✓ Branch 0 taken 136 times.
✓ Branch 1 taken 15735 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 136 times.
15871 if(wpn==ewFlame || wpn==ewFlame2)
1813 {
1814
2/4
✓ Branch 0 taken 15735 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 15735 times.
15735 if(fire_angle==-PI || fire_angle==PI) wdir=left;
1815
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15735 times.
15735 else if(fire_angle==-PI/2) wdir=up;
1816
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15735 times.
15735 else if(fire_angle==PI/2) wdir=down;
1817
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15735 times.
15735 else if(fire_angle==0) wdir=right;
1818
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15735 times.
15735 else if(fire_angle<-PI/2) wdir=l_up;
1819
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15735 times.
15735 else if(fire_angle<0) wdir=r_up;
1820
2/2
✓ Branch 0 taken 1498 times.
✓ Branch 1 taken 14237 times.
15735 else if(fire_angle<(PI/2)) wdir=r_down;
1821
2/2
✓ Branch 0 taken 10121 times.
✓ Branch 1 taken 4116 times.
14237 else if(fire_angle<PI) wdir=l_down;
1822 15735 }
1823 15871 }
1824 else
1825 {
1826 5081 wx = x;
1827 5081 wy = y;
1828 }
1829
1830
2/2
✓ Branch 0 taken 5081 times.
✓ Branch 1 taken 15871 times.
20952 addEwpn(wx,wy,z,wpn,2,wdp,seekhero ? 0xFF : wdir, getUID(), 0, fakez);
1831 20952 sfx(wpnsfx(wpn),pan(int32_t(x)));
1832
1833 20952 int32_t i=Ewpns.Count()-1;
1834 20952 weapon *ew = (weapon*)(Ewpns.spr(i));
1835 20952 ew->moveflags &= ~move_can_pitfall; //No falling in pits
1836
1837
4/4
✓ Branch 0 taken 15871 times.
✓ Branch 1 taken 5081 times.
✓ Branch 2 taken 7914 times.
✓ Branch 3 taken 7957 times.
20952 if(!seekhero && (zc_oldrand()&4))
1838 {
1839 7957 ew->angular=true;
1840 7957 ew->angle=fire_angle;
1841 7957 }
1842
1843
4/4
✓ Branch 0 taken 20676 times.
✓ Branch 1 taken 276 times.
✓ Branch 2 taken 317 times.
✓ Branch 3 taken 20359 times.
20952 if(wpn==ewFlame && wpnsbuf[ewFLAME].frames>1)
1844 {
1845 20359 ew->aframe=zc_oldrand()%wpnsbuf[ewFLAME].frames;
1846
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 20359 times.
20359 if ( ew->do_animation ) ew->tile+=ew->aframe;
1847 20359 }
1848
1849
2/2
✓ Branch 0 taken 20952 times.
✓ Branch 1 taken 766199 times.
787151 for(int32_t j=Ewpns.Count()-1; j>0; j--)
1850 {
1851 766199 Ewpns.swap(j,j-1);
1852 766199 }
1853 20952 }
1854
1855 44653 void enemy::FireWeapon()
1856 {
1857 /*
1858 * Type:
1859 * 0x01: Boss fireball
1860 * 0x02: Seeks Hero
1861 * 0x04: Fast projectile
1862 * 0x00-0x30: If 0x02, slants toward (type>>3)-1
1863 */
1864
1865
2/2
✓ Branch 0 taken 44522 times.
✓ Branch 1 taken 131 times.
44653 if (wpn < 1) return;
1866
1/10
✗ Branch 0 not taken.
✓ Branch 1 taken 44522 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
44522 if(wpn<wEnemyWeapons && dmisc1!=9 && dmisc1!=10 && (wpn < wScript1 && wpn > wScript10) ) // Summoning doesn't require weapons
1867 return;
1868
1869
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 44522 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
44522 if(wpn==ewFireTrail && dmisc1>=e1t3SHOTS && dmisc1<=e1t8SHOTS)
1870 dmisc1 = e1tEACHTILE;
1871
1872 44522 int32_t xoff = 0;
1873 44522 int32_t yoff = 0;
1874
1/2
✓ Branch 0 taken 44522 times.
✗ Branch 1 not taken.
44522 if ( SIZEflags&OVERRIDE_HIT_WIDTH )
1875 {
1876 xoff += (hit_width/2)-8;
1877 //Z_scripterrlog("width flag enabled. xoff = %d\n", xoff);
1878 }
1879
1/2
✓ Branch 0 taken 44522 times.
✗ Branch 1 not taken.
44522 if ( SIZEflags&OVERRIDE_HIT_HEIGHT )
1880 {
1881 yoff += (hit_height/2)-8;
1882 //Z_scripterrlog("width flag enabled. yoff = %d\n", yoff);
1883 }
1884
1885
5/8
✓ Branch 0 taken 646 times.
✓ Branch 1 taken 41523 times.
✓ Branch 2 taken 1839 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 416 times.
✓ Branch 5 taken 98 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
44522 switch(dmisc1)
1886 {
1887 case e1t5SHOTS: //BS-Aquamentus
1888 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,2+(((dir^left)+5)<<3),wdp,dir,-1, getUID(),false));
1889 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1890 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,2+(((dir^right)+5)<<3),wdp,dir,-1, getUID(),false));
1891 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1892
1893 [[fallthrough]];
1894 case e1t3SHOTSFAST:
1895 case e1t3SHOTS: //Aquamentus
1896
7/14
✓ Branch 0 taken 646 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 646 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 646 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 646 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 646 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 646 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 646 times.
✗ Branch 13 not taken.
646 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,2+(((dir^left)+1)<<3)+(dmisc1==e1t3SHOTSFAST ? 4:0),wdp,dir,-1, getUID(),false));
1897 646 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1898
7/14
✓ Branch 0 taken 646 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 646 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 646 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 646 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 646 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 646 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 646 times.
✗ Branch 13 not taken.
646 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,2+(((dir^right)+1)<<3)+(dmisc1==e1t3SHOTSFAST ? 4:0),wdp,dir,-1, getUID(),false));
1899 646 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1900
1901 [[fallthrough]];
1902 default:
1903
12/20
✓ Branch 0 taken 42169 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 42169 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 42169 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 42169 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 42169 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 5 times.
✓ Branch 11 taken 42164 times.
✓ Branch 12 taken 42169 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 18238 times.
✓ Branch 15 taken 23931 times.
✓ Branch 16 taken 42169 times.
✗ Branch 17 not taken.
✓ Branch 18 taken 42169 times.
✗ Branch 19 not taken.
42169 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,2+(dmisc1==e1t3SHOTSFAST || dmisc1==e1tFAST ? 4:0),wdp,wpn==ewFireball2 || wpn==ewFireball ? 0:dir,-1, getUID(),false));
1904 42169 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1905 42169 sfx(wpnsfx(wpn),pan(int32_t(x)));
1906 42169 break;
1907
1908 case e1tSLANT:
1909 {
1910 416 int32_t slant = 0;
1911
1912
10/10
✓ Branch 0 taken 112 times.
✓ Branch 1 taken 304 times.
✓ Branch 2 taken 200 times.
✓ Branch 3 taken 216 times.
✓ Branch 4 taken 47 times.
✓ Branch 5 taken 161 times.
✓ Branch 6 taken 61 times.
✓ Branch 7 taken 316 times.
✓ Branch 8 taken 138 times.
✓ Branch 9 taken 178 times.
416 if(((Hero.x-x) < -8 && dir==up) || ((Hero.x-x) > 8 && dir==down) || ((Hero.y-y) < -8 && dir==left) || ((Hero.y-y) > 8 && dir==right))
1913 246 slant = left;
1914
10/10
✓ Branch 0 taken 94 times.
✓ Branch 1 taken 84 times.
✓ Branch 2 taken 68 times.
✓ Branch 3 taken 108 times.
✓ Branch 4 taken 37 times.
✓ Branch 5 taken 33 times.
✓ Branch 6 taken 55 times.
✓ Branch 7 taken 86 times.
✓ Branch 8 taken 25 times.
✓ Branch 9 taken 61 times.
178 else if(((Hero.x-x) > 8 && dir==up) || ((Hero.x-x) < -8 && dir==down) || ((Hero.y-y) > 8 && dir==left) || ((Hero.y-y) < -8 && dir==right))
1915 117 slant = right;
1916
1917
9/18
✓ Branch 0 taken 330 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 330 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 330 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 330 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 330 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 330 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✓ Branch 13 taken 330 times.
✓ Branch 14 taken 330 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 330 times.
✗ Branch 17 not taken.
330 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,2+(((dir^slant)+1)<<3),wdp,wpn==ewFireball2 || wpn==ewFireball ? 0:dir,-1, getUID(),false));
1918 330 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1919 330 sfx(wpnsfx(wpn),pan(int32_t(x)));
1920 330 break;
1921 }
1922
1923 case e1t8SHOTS: //Fire Wizzrobe
1924
7/14
✓ Branch 0 taken 98 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 98 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 98 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 98 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 98 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 98 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 98 times.
✗ Branch 13 not taken.
98 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,0,wdp,l_up,-1, getUID(),false));
1925 98 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1926 98 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
1927
7/14
✓ Branch 0 taken 98 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 98 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 98 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 98 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 98 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 98 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 98 times.
✗ Branch 13 not taken.
98 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,0,wdp,l_down,-1, getUID(),false));
1928 98 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1929 98 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
1930
7/14
✓ Branch 0 taken 98 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 98 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 98 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 98 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 98 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 98 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 98 times.
✗ Branch 13 not taken.
98 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,0,wdp,r_up,-1, getUID(),false));
1931 98 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1932 98 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
1933
7/14
✓ Branch 0 taken 98 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 98 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 98 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 98 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 98 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 98 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 98 times.
✗ Branch 13 not taken.
98 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,0,wdp,r_down,-1, getUID(),false));
1934 98 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1935 98 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
1936
1937 [[fallthrough]];
1938 case e1t4SHOTS: //Stalfos 3
1939
7/14
✓ Branch 0 taken 1937 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1937 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1937 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1937 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1937 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 1937 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 1937 times.
✗ Branch 13 not taken.
1937 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,0,wdp,up,-1, getUID(),false));
1940 1937 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1941 1937 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
1942
7/14
✓ Branch 0 taken 1937 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1937 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1937 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1937 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1937 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 1937 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 1937 times.
✗ Branch 13 not taken.
1937 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,0,wdp,down,-1, getUID(),false));
1943 1937 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1944 1937 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
1945
7/14
✓ Branch 0 taken 1937 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1937 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1937 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1937 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1937 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 1937 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 1937 times.
✗ Branch 13 not taken.
1937 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,0,wdp,left,-1, getUID(),false));
1946 1937 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1947 1937 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
1948
7/14
✓ Branch 0 taken 1937 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1937 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1937 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1937 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1937 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 1937 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 1937 times.
✗ Branch 13 not taken.
1937 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,0,wdp,right,-1, getUID(),false));
1949 1937 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1950 1937 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
1951 1937 sfx(wpnsfx(wpn),pan(int32_t(x)));
1952 1937 break;
1953
1954 case e1tSUMMON: // Bat Wizzrobe
1955 {
1956 if(dmisc4==0) break; // Summon 0
1957
1958 int32_t bc=0;
1959
1960 for(int32_t gc=0; gc<guys.Count(); gc++)
1961 {
1962 if((((enemy*)guys.spr(gc))->id) == dmisc3)
1963 {
1964 ++bc;
1965 }
1966 }
1967
1968 if(bc<=40) // Not too many enemies
1969 {
1970 int32_t kids = guys.Count();
1971 int32_t bats=(zc_oldrand()%zc_max(1,dmisc4))+1;
1972
1973 for(int32_t i=0; i<bats; i++)
1974 {
1975 if(addchild(x,y,dmisc3,-10, this->script_UID))
1976 {
1977 ((enemy*)guys.spr(kids+i))->count_enemy = false;
1978
1979 }
1980 }
1981
1982 sfx(firesfx, pan(int32_t(x)));
1983 }
1984
1985 break;
1986 }
1987
1988 case e1tSUMMONLAYER: // Summoner
1989 {
1990 if(count_layer_enemies()==0)
1991 {
1992 break;
1993 }
1994
1995 int32_t kids = guys.Count();
1996
1997 if(kids<40)
1998 {
1999 int32_t newguys=(zc_oldrand()%3)+1;
2000 bool summoned=false;
2001
2002 for(int32_t i=0; i<newguys; i++)
2003 {
2004 int32_t id2=vbound(random_layer_enemy(),eSTART,eMAXGUYS-1);
2005 int32_t x2=0;
2006 int32_t y2=0;
2007
2008 for(int32_t k=0; k<20; ++k)
2009 {
2010 x2=16*((zc_oldrand()%12)+2);
2011 y2=16*((zc_oldrand()%7)+2);
2012
2013 if((!m_walkflag(x2,y2,0,dir))&&((abs(x2-Hero.getX())>=32)||(abs(y2-Hero.getY())>=32)))
2014 {
2015 if(addchild(x2,y2,get_qr(qr_ENEMIESZAXIS) ? 64 : 0,id2,-10, this->script_UID))
2016 {
2017 ((enemy*)guys.spr(kids+i))->count_enemy = false;
2018 if (get_qr(qr_ENEMIESZAXIS) && (((enemy*)guys.spr(kids+i))->moveflags & move_use_fake_z))
2019 {
2020 ((enemy*)guys.spr(kids+i))->fakez = 64;
2021 ((enemy*)guys.spr(kids+i))->z = 0;
2022 }
2023 }
2024
2025 summoned=true;
2026 break;
2027 }
2028 }
2029 }
2030
2031 if(summoned)
2032 {
2033 sfx(firesfx, pan(int32_t(x)));
2034 }
2035 }
2036
2037 break;
2038 }
2039 }
2040 44567 }
2041
2042
2043 // Hit the shield(s)?
2044 // Apparently, this function is only used for hookshots...
2045 2767 bool enemy::hitshield(int32_t wpnx, int32_t wpny, int32_t xdir)
2046 {
2047
6/6
✓ Branch 0 taken 976 times.
✓ Branch 1 taken 1791 times.
✓ Branch 2 taken 975 times.
✓ Branch 3 taken 1 times.
✓ Branch 4 taken 141 times.
✓ Branch 5 taken 834 times.
2767 if(!(family==eeWALK || family==eeFIRE || family==eeOTHER))
2048 834 return false;
2049
2050 1933 bool ret = false;
2051
2052 // TODO: There must be some bitwise operations that can simplify this...
2053
9/12
✓ Branch 0 taken 1207 times.
✓ Branch 1 taken 726 times.
✓ Branch 2 taken 43 times.
✓ Branch 3 taken 683 times.
✓ Branch 4 taken 27 times.
✓ Branch 5 taken 16 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 699 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 699 times.
✓ Branch 10 taken 699 times.
✗ Branch 11 not taken.
1933 if(wpny > y) ret = ((flags&guy_shield_front && xdir==down) || (flags&guy_shield_back && xdir==up) || (flags&guy_shield_left && xdir==left) || (flags&guy_shield_right && xdir==right));
2054
9/12
✓ Branch 0 taken 383 times.
✓ Branch 1 taken 824 times.
✓ Branch 2 taken 46 times.
✓ Branch 3 taken 778 times.
✓ Branch 4 taken 33 times.
✓ Branch 5 taken 13 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 811 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 811 times.
✓ Branch 10 taken 811 times.
✗ Branch 11 not taken.
1207 else if(wpny < y) ret = ((flags&guy_shield_front && xdir==up) || (flags&guy_shield_back && xdir==down) || (flags&guy_shield_left && xdir==right) || (flags&guy_shield_right && xdir==left));
2055
2056
11/14
✓ Branch 0 taken 1065 times.
✓ Branch 1 taken 868 times.
✓ Branch 2 taken 19 times.
✓ Branch 3 taken 849 times.
✓ Branch 4 taken 24 times.
✓ Branch 5 taken 825 times.
✓ Branch 6 taken 9 times.
✓ Branch 7 taken 15 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 840 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 840 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 840 times.
1933 if(wpnx < x) ret = ret || ((flags&guy_shield_front && xdir==left) || (flags&guy_shield_back && xdir==right) || (flags&guy_shield_left && xdir==down) || (flags&guy_shield_right && xdir==up));
2057
11/14
✓ Branch 0 taken 189 times.
✓ Branch 1 taken 876 times.
✓ Branch 2 taken 13 times.
✓ Branch 3 taken 863 times.
✓ Branch 4 taken 36 times.
✓ Branch 5 taken 827 times.
✓ Branch 6 taken 19 times.
✓ Branch 7 taken 17 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 844 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 844 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 844 times.
1065 else if(wpnx > x) ret = ret || ((flags&guy_shield_front && xdir==right) || (flags&guy_shield_back && xdir==left) || (flags&guy_shield_left && xdir==up) || (flags&guy_shield_right && xdir==down));
2058
2059 1933 return ret;
2060 2767 }
2061
2062
2063 //! Weapon Editor for 2.6
2064 //To hell with this. I'm writing new functions to resolve weapon type and defence. -Z
2065
2066
2067 //converts a wqeapon ID to its defence index.
2068 126851 int32_t weaponToDefence(int32_t wid)
2069 {
2070
23/47
✗ Branch 0 not taken.
✓ Branch 1 taken 64409 times.
✓ Branch 2 taken 9432 times.
✓ Branch 3 taken 25029 times.
✓ Branch 4 taken 4207 times.
✓ Branch 5 taken 37 times.
✓ Branch 6 taken 48 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 3146 times.
✓ Branch 9 taken 9836 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✓ Branch 12 taken 269 times.
✓ Branch 13 taken 1217 times.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✓ Branch 16 taken 512 times.
✓ Branch 17 taken 1459 times.
✗ Branch 18 not taken.
✓ Branch 19 taken 2036 times.
✓ Branch 20 taken 2767 times.
✓ Branch 21 taken 610 times.
✗ Branch 22 not taken.
✓ Branch 23 taken 240 times.
✓ Branch 24 taken 469 times.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
✓ Branch 28 taken 19 times.
✗ Branch 29 not taken.
✓ Branch 30 taken 26 times.
✗ Branch 31 not taken.
✓ Branch 32 taken 12 times.
✓ Branch 33 taken 77 times.
✗ Branch 34 not taken.
✗ Branch 35 not taken.
✗ Branch 36 not taken.
✗ Branch 37 not taken.
✗ Branch 38 not taken.
✓ Branch 39 taken 993 times.
✗ Branch 40 not taken.
✗ Branch 41 not taken.
✓ Branch 42 taken 1 times.
✗ Branch 43 not taken.
✗ Branch 44 not taken.
✗ Branch 45 not taken.
✗ Branch 46 not taken.
126851 switch(wid)
2071 {
2072 case wNone: return -1;
2073 64409 case wSword: return edefSWORD;
2074 9432 case wBeam: return edefBEAM;
2075 25029 case wBrang: return edefBRANG;
2076 4207 case wBomb: return edefBOMB;
2077 37 case wSBomb: return edefSBOMB;
2078 48 case wLitBomb: return edefBOMB;
2079 case wLitSBomb: return edefSBOMB;
2080 3146 case wArrow: return edefARROW;
2081 9836 case wFire: return edefFIRE;
2082 case wWhistle:
2083 {
2084 return edefWhistle;
2085 }
2086 case wBait: return edefBAIT;
2087 269 case wWand: return edefWAND;
2088 1217 case wMagic: return edefMAGIC;
2089 case wCatching: return -1;
2090 case wWind: return edefWIND;
2091 512 case wRefMagic: return edefREFMAGIC;
2092 1459 case wRefFireball: return edefREFBALL;
2093 case wRefRock: return edefREFROCK;
2094 2036 case wHammer: return edefHAMMER;
2095 2767 case wHookshot: return edefHOOKSHOT;
2096 610 case wHSHandle: return edefHOOKSHOT;
2097 case wHSChain: return edefHOOKSHOT;
2098 240 case wSSparkle: return edefSPARKLE;
2099 469 case wFSparkle: return edefSPARKLE;
2100 case wSmack: return -1; // is this the candle object?
2101 case wPhantom: return -1; //engine created visual effects.
2102 case wCByrna: return edefBYRNA;
2103 19 case wRefBeam: return edefREFBEAM;
2104 case wStomp: return edefSTOMP;
2105 26 case wScript1: return edefSCRIPT01;
2106 case wScript2: return edefSCRIPT02;
2107 12 case wScript3: return edefSCRIPT03;
2108 77 case wScript4: return edefSCRIPT04;
2109 case wScript5: return edefSCRIPT05;
2110 case wScript6: return edefSCRIPT06;
2111 case wScript7: return edefSCRIPT07;
2112 case wScript8: return edefSCRIPT08;
2113 case wScript9: return edefSCRIPT09;
2114 993 case wScript10: return edefSCRIPT10;
2115 case wIce: return edefICE;
2116 case wSound: return edefSONIC;
2117 1 case wThrown: return edefTHROWN;
2118 case wRefArrow: return edefREFARROW;
2119 case wRefFire: return edefREFFIRE;
2120 case wRefFire2: return edefREFFIRE2;
2121 //case wPot: return edefPOT;
2122 // case wLitZap: return edefELECTRIC;
2123 // case wZ3Sword: return edefZ3SWORD;
2124 // case wLASWord: return edefLASWORD;
2125 // case wSpinAttk: return edefSPINATTK;
2126 // case wShield: return edefSHIELD;
2127 // case wTrowel: return edefTROWEL;
2128
2129 default: return -1;
2130 }
2131 126851 }
2132
2133 126851 int32_t getDefType(weapon *w)
2134 {
2135 126851 int32_t id = getWeaponID(w);
2136 126851 int32_t edef = weaponToDefence(id);
2137
2/2
✓ Branch 0 taken 123474 times.
✓ Branch 1 taken 3377 times.
126851 if(edef == edefHOOKSHOT)
2138 {
2139
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3377 times.
3377 if(w->family_class == itype_switchhook)
2140 return edefSwitchHook;
2141 3377 }
2142 126851 return edef;
2143 126851 }
2144
2145 225906 int32_t getWeaponID(weapon *w)
2146 {
2147 225906 int32_t usewpn = w->useweapon;
2148
2/2
✓ Branch 0 taken 230 times.
✓ Branch 1 taken 225676 times.
225906 return (usewpn > 0) ? usewpn : w->id;
2149 }
2150
2151 126851 int32_t enemy::resolveEnemyDefence(weapon *w)
2152 {
2153 //sword edef is 9, but we're reading it at 0
2154 //,
2155 126851 int32_t weapondef = 0;
2156 126851 int32_t wdeftype = getDefType(w);
2157 126851 int32_t usedef = w->usedefence;
2158
2159
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 126851 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
126851 if ( usedef > 0 && (wdeftype < 0 || wdeftype >= edefLAST255 || defense[wdeftype] == 0))
2160 {
2161 weapondef = usedef*-1;
2162 }
2163
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 126851 times.
126851 else if(unsigned(wdeftype) < edefLAST255)
2164 {
2165 126851 weapondef = wdeftype;
2166 126851 }
2167 126851 return weapondef;
2168 }
2169
2170 137394 byte get_def_ignrflag(int32_t edef)
2171 {
2172
3/3
✓ Branch 0 taken 114464 times.
✓ Branch 1 taken 3668 times.
✓ Branch 2 taken 19262 times.
137394 switch(edef)
2173 {
2174 case edIGNORE:
2175 case edIGNOREL1:
2176 case edSTUNORIGNORE:
2177 19262 return WPNUNB_IGNR;
2178 case edSTUNORCHINK:
2179 case edCHINK:
2180 case edCHINKL1:
2181 case edCHINKL2:
2182 case edCHINKL4:
2183 case edCHINKL6:
2184 case edCHINKL8:
2185 case edCHINKL10:
2186 case edLEVELCHINK2:
2187 case edLEVELCHINK3:
2188 case edLEVELCHINK4:
2189 case edLEVELCHINK5:
2190 3668 return WPNUNB_BLOCK;
2191 }
2192 114464 return 0;
2193 137394 }
2194
2195 137394 int32_t conv_edef_unblockable(int32_t edef, byte unblockable)
2196 {
2197
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 137394 times.
137394 if(!(unblockable&get_def_ignrflag(edef))) return edef;
2198 switch(edef)
2199 {
2200 case edIGNORE:
2201 case edIGNOREL1:
2202 case edCHINK:
2203 case edCHINKL1:
2204 case edCHINKL2:
2205 case edCHINKL4:
2206 case edCHINKL6:
2207 case edCHINKL8:
2208 case edCHINKL10:
2209 case edLEVELCHINK2:
2210 case edLEVELCHINK3:
2211 case edLEVELCHINK4:
2212 case edLEVELCHINK5:
2213 return edNORMAL;
2214 case edSTUNORIGNORE:
2215 case edSTUNORCHINK:
2216 return edSTUNONLY;
2217 }
2218 return edef;
2219 137394 }
2220
2221 // Do we do damage?
2222 // 0: takehit returns 0
2223 // 1: takehit returns 1
2224 // -1: do damage
2225 //The input from resolveEnemyDefence() for the param 'edef' is negative if a specific defence RESULT is being used.
2226 125858 int32_t enemy::defendNew(int32_t wpnId, int32_t *power, int32_t edef, byte unblockable) //May need *wpn to set return on brangs and hookshots
2227 {
2228
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 125858 times.
125858 if(switch_hooked) return 0;
2229 125858 int32_t tempx = x;
2230 125858 int32_t tempy = y;
2231 125858 int32_t the_defence = 0;
2232
1/2
✓ Branch 0 taken 125858 times.
✗ Branch 1 not taken.
125858 if ( edef < 0 ) //we are using a specific base default defence for a weapon
2233 {
2234 the_defence = edef*-1; //A specific defence type.
2235 }
2236 125858 else the_defence = defense[edef];
2237
2238 125858 the_defence = conv_edef_unblockable(the_defence, unblockable);
2239
2240
3/4
✓ Branch 0 taken 6573 times.
✓ Branch 1 taken 119285 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6573 times.
125858 if(shieldCanBlock && !(unblockable&WPNUNB_SHLD))
2241 {
2242
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 6566 times.
✓ Branch 2 taken 7 times.
6573 switch(the_defence)
2243 {
2244 case edIGNORE:
2245 7 return 0;
2246 case edIGNOREL1:
2247 case edSTUNORIGNORE:
2248 if(*power <= 0)
2249 return 0;
2250 }
2251 6566 sfx(WAV_CHINK,pan(int32_t(x)));
2252 6566 return 1;
2253 }
2254
2255 119285 int32_t new_id = id;
2256 119285 int32_t effect_type = dmisc15;
2257 119285 int32_t delay_timer = 90;
2258 119285 enemy *gleeok = NULL;
2259 119285 enemy *ptra = NULL;
2260 119285 int32_t c = 0;
2261
2262
16/29
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 492 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1931 times.
✓ Branch 6 taken 1862 times.
✓ Branch 7 taken 113 times.
✓ Branch 8 taken 129 times.
✓ Branch 9 taken 1 times.
✓ Branch 10 taken 43 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 930 times.
✓ Branch 13 taken 17324 times.
✓ Branch 14 taken 883 times.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✓ Branch 19 taken 2175 times.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✓ Branch 22 taken 71 times.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✓ Branch 25 taken 158 times.
✓ Branch 26 taken 105 times.
✓ Branch 27 taken 4 times.
✓ Branch 28 taken 93064 times.
119285 switch(the_defence)
2263 {
2264 case edREPLACE:
2265 {
2266 sclk = 0;
2267 if ( dmisc16 > 0 ) new_id = dmisc16;
2268 else new_id = id+1;
2269 if ( new_id > 511 ) new_id = id; //Sanity bound to legal enemy IDs.
2270 if ( dmisc17 > 0 ) delay_timer = dmisc17;
2271 //if ( dmisc18 > 0 ) dummy_wpn_id = dmisc18;
2272
2273 //Z_scripterrlog("new id is %d\n", new_id);
2274 switch(guysbuf[new_id&0xFFF].family)
2275 {
2276 //Fixme: possible enemy memory leak. (minor)
2277 case eeWALK:
2278 {
2279 enemy *e = new eStalfos(x,y,new_id,clk);
2280 guys.add(e);
2281 }
2282 break;
2283
2284 case eeLEV:
2285 {
2286 enemy *e = new eLeever(x,y,new_id,clk);
2287 guys.add(e);
2288 }
2289 break;
2290
2291 case eeTEK:
2292 {
2293 enemy *e = new eTektite(x,y,new_id,clk);
2294 guys.add(e);
2295 }
2296 break;
2297
2298 case eePEAHAT:
2299 {
2300 enemy *e = new ePeahat(x,y,new_id,clk);
2301 guys.add(e);
2302 }
2303 break;
2304
2305 case eeZORA:
2306 {
2307 enemy *e = new eZora(x,y,new_id,clk);
2308 guys.add(e);
2309 }
2310 break;
2311
2312 case eeGHINI:
2313 {
2314 enemy *e = new eGhini(x,y,new_id,clk);
2315 guys.add(e);
2316 }
2317 break;
2318
2319 case eeKEESE:
2320 {
2321 enemy *e = new eKeese(x,y,new_id,clk);
2322 guys.add(e);
2323 }
2324 break;
2325
2326 case eeWIZZ:
2327 {
2328 enemy *e = new eWizzrobe(x,y,new_id,clk);
2329 guys.add(e);
2330 }
2331 break;
2332
2333 case eePROJECTILE:
2334 {
2335 enemy *e = new eProjectile(x,y,new_id,clk);
2336 guys.add(e);
2337 }
2338 break;
2339
2340 case eeWALLM:
2341 {
2342 enemy *e = new eWallM(x,y,new_id,clk);
2343 guys.add(e);
2344 }
2345 break;
2346
2347 case eeAQUA:
2348 {
2349 enemy *e = new eAquamentus(x,y,new_id,clk);
2350 guys.add(e);
2351 e->x = x;
2352 e->y = y;
2353 }
2354 break;
2355
2356 case eeMOLD:
2357 {
2358 enemy *e = new eMoldorm(x,y,new_id,zc_max(1,zc_min(254,guysbuf[new_id&0xFFF].attributes[0])));
2359 guys.add(e);
2360 e->x = x;
2361 e->y = y;
2362 }
2363 break;
2364
2365 case eeMANHAN:
2366 {
2367 enemy *e = new eManhandla(x,y,new_id,clk);
2368 guys.add(e);
2369 e->x = x;
2370 e->y = y;
2371 }
2372 break;
2373
2374 case eeGLEEOK:
2375 {
2376 *power = 0;
2377 gleeok = new eGleeok(x,y,new_id,guysbuf[new_id&0xFFF].attributes[0]);
2378 guys.add(gleeok);
2379 ((enemy*)guys.spr(guys.Count()-1))->hclk = delay_timer;
2380 new_id &= 0xFFF;
2381 int32_t head_cnt = zc_max(1,zc_min(254,guysbuf[new_id&0xFFF].attributes[0]));
2382 Z_scripterrlog("Gleeok head count is %d\n",head_cnt);
2383 for(int32_t i=0; i<head_cnt; i++)
2384 {
2385 //enemy *e = new esGleeok(x,y,new_id+0x1000,clk,gleeok);
2386 if(!guys.add(new esGleeok((zfix)x,(zfix)y,new_id+0x1000,c, gleeok)))
2387 {
2388 al_trace("Gleeok head %d could not be created!\n",i+1);
2389
2390 for(int32_t j=0; j<i+1; j++)
2391 {
2392 guys.del(guys.Count()-1);
2393 }
2394
2395 break;
2396 }
2397 else
2398 {
2399 ((enemy*)guys.spr(guys.Count()-1))->hclk = delay_timer;
2400 }
2401
2402 c-=guysbuf[new_id].attributes[3];
2403 //gleeok->x = x;
2404 //gleeok->y = y;
2405 //gleeok = e;
2406 }
2407 return 1;
2408 }
2409
2410 case eeGHOMA:
2411 {
2412 enemy *e = new eGohma(x,y,new_id,clk);
2413 guys.add(e);
2414 e->x = x;
2415 e->y = y;
2416 }
2417 break;
2418
2419 case eeLANM:
2420 {
2421 enemy *e = new eLanmola(x,y,new_id,zc_max(1,zc_min(253,guysbuf[new_id&0xFFF].attributes[0])));
2422 guys.add(e);
2423 e->x = x;
2424 e->y = y;
2425 }
2426 break;
2427
2428 case eeGANON:
2429 {
2430 enemy *e = new eGanon(x,y,new_id,clk);
2431 guys.add(e);
2432 e->x = x;
2433 e->y = y;
2434 }
2435 break;
2436
2437 case eeFAIRY:
2438 {
2439 enemy *e = new eItemFairy(x,y,new_id+0x1000*clk,clk);
2440 guys.add(e);
2441 e->x = x;
2442 e->y = y;
2443 }
2444 break;
2445
2446 case eeFIRE:
2447 {
2448 enemy *e = new eFire(x,y,new_id,clk);
2449 guys.add(e);
2450 e->x = x;
2451 e->y = y;
2452 }
2453 break;
2454
2455 case eeOTHER:
2456 {
2457 enemy *e = new eOther(x,y,new_id,clk);
2458 guys.add(e);
2459 e->x = x;
2460 e->y = y;
2461 }
2462 break;
2463
2464 case eeSPINTILE:
2465 {
2466 enemy *e = new eSpinTile(x,y,new_id,clk);
2467 guys.add(e);
2468 e->x = x;
2469 e->y = y;
2470 }
2471 break;
2472
2473 // and these enemies use the misc10/misc2 value
2474 case eeROCK:
2475 {
2476 switch(guysbuf[new_id&0xFFF].attributes[9])
2477 {
2478 case 1:
2479 {
2480 enemy *e = new eBoulder(x,y,new_id,clk);
2481 guys.add(e);
2482 e->x = x;
2483 e->y = y;
2484 }
2485 break;
2486
2487 case 0:
2488 default:
2489 {
2490 enemy *e = new eRock(x,y,new_id,clk);
2491 guys.add(e);
2492 e->x = x;
2493 e->y = y;
2494 }
2495 break;
2496 }
2497
2498 break;
2499 }
2500
2501 case eeTRAP:
2502 {
2503 switch(guysbuf[new_id&0xFFF].attributes[1])
2504 {
2505 case 1:
2506 {
2507 enemy *e = new eTrap2(x,y,new_id,clk);
2508 guys.add(e);
2509 e->x = x;
2510 e->y = y;
2511 }
2512 break;
2513
2514 case 0:
2515 default:
2516 {
2517 enemy *e = new eTrap(x,y,new_id,clk);
2518 guys.add(e);
2519 e->x = x;
2520 e->y = y;
2521 }
2522 break;
2523 }
2524
2525 break;
2526 }
2527
2528 case eeDONGO:
2529 {
2530 switch(guysbuf[new_id&0xFFF].attributes[9])
2531 {
2532 case 1:
2533 {
2534 enemy *e = new eDodongo2(x,y,new_id,clk);
2535 guys.add(e);
2536 e->x = x;
2537 e->y = y;
2538 }
2539 break;
2540
2541 case 0:
2542 default:
2543 {
2544 enemy *e = new eDodongo(x,y,new_id,clk);
2545 guys.add(e);
2546 e->x = x;
2547 e->y = y;
2548 }
2549 break;
2550 }
2551
2552 break;
2553 }
2554
2555 case eeDIG:
2556 {
2557 switch(guysbuf[new_id&0xFFF].attributes[9])
2558 {
2559 case 1:
2560 {
2561 enemy *e = new eLilDig(x,y,new_id,clk);
2562 guys.add(e);
2563 e->x = x;
2564 e->y = y;
2565 }
2566 break;
2567
2568 case 0:
2569 default:
2570 {
2571 enemy *e = new eBigDig(x,y,new_id,clk);
2572 guys.add(e);
2573 e->x = x;
2574 e->y = y;
2575 }
2576 break;
2577 }
2578
2579 break;
2580 }
2581
2582 case eePATRA:
2583 {
2584 switch(guysbuf[new_id&0xFFF].attributes[9])
2585 {
2586 case 1:
2587 {
2588 if (get_qr(qr_HARDCODED_BS_PATRA))
2589 {
2590 enemy *e = new ePatraBS(x,y,new_id,clk);
2591 guys.add(e);
2592 e->x = x;
2593 e->y = y;
2594 break;
2595 }
2596 }
2597 [[fallthrough]];
2598 case 0:
2599 default:
2600 {
2601 enemy *e = new ePatra(x,y,new_id,clk);
2602 guys.add(e);
2603 e->x = x;
2604 e->y = y;
2605 }
2606 break;
2607 }
2608
2609 break;
2610 }
2611
2612 case eeGUY:
2613 {
2614 switch(guysbuf[new_id&0xFFF].attributes[9])
2615 {
2616 case 1:
2617 {
2618 enemy *e = new eTrigger(x,y,new_id,clk);
2619 guys.add(e);
2620 }
2621 break;
2622
2623 case 0:
2624 default:
2625 {
2626 enemy *e = new eNPC(x,y,new_id,clk);
2627 guys.add(e);
2628 }
2629 break;
2630 }
2631
2632 break;
2633 }
2634
2635 case eeSCRIPT01:
2636 case eeSCRIPT02:
2637 case eeSCRIPT03:
2638 case eeSCRIPT04:
2639 case eeSCRIPT05:
2640 case eeSCRIPT06:
2641 case eeSCRIPT07:
2642 case eeSCRIPT08:
2643 case eeSCRIPT09:
2644 case eeSCRIPT10:
2645 case eeSCRIPT11:
2646 case eeSCRIPT12:
2647 case eeSCRIPT13:
2648 case eeSCRIPT14:
2649 case eeSCRIPT15:
2650 case eeSCRIPT16:
2651 case eeSCRIPT17:
2652 case eeSCRIPT18:
2653 case eeSCRIPT19:
2654 case eeSCRIPT20:
2655 {
2656 enemy *e = new eScript(x,y,new_id,clk);
2657 guys.add(e);
2658 e->x = x;
2659 e->y = y;
2660 break;
2661 }
2662
2663
2664 case eeFFRIENDLY01:
2665 case eeFFRIENDLY02:
2666 case eeFFRIENDLY03:
2667 case eeFFRIENDLY04:
2668 case eeFFRIENDLY05:
2669 case eeFFRIENDLY06:
2670 case eeFFRIENDLY07:
2671 case eeFFRIENDLY08:
2672 case eeFFRIENDLY09:
2673 case eeFFRIENDLY10:
2674 {
2675 enemy *e = new eFriendly(x,y,new_id,clk);
2676 guys.add(e);
2677 e->x = x;
2678 e->y = y;
2679 break;
2680 }
2681
2682
2683 default: break;
2684 }
2685
2686 // add segments of segmented enemies
2687 int32_t c=0;
2688
2689 switch(guysbuf[new_id&0xFFF].family)
2690 {
2691 case eeMOLD:
2692 {
2693 byte is=((enemy*)guys.spr(guys.Count()-1))->item_set;
2694 new_id &= 0xFFF;
2695
2696 for(int32_t i=0; i<zc_max(1,zc_min(254,guysbuf[new_id].attributes[0])); i++)
2697 {
2698 //christ this is messy -DD
2699 int32_t segclk = -i*((int32_t)(8.0/(zslongToFix(guysbuf[new_id&0xFFF].step*100))));
2700
2701 if(!guys.add(new esMoldorm((zfix)x,(zfix)y,new_id+0x1000,segclk)))
2702 {
2703 al_trace("Moldorm segment %d could not be created!\n",i+1);
2704
2705 for(int32_t j=0; j<i+1; j++)
2706 guys.del(guys.Count()-1);
2707
2708 return 0;
2709 }
2710
2711 if(i>0)
2712 ((enemy*)guys.spr(guys.Count()-1))->item_set=is;
2713
2714
2715 }
2716
2717 break;
2718 }
2719
2720 case eeLANM:
2721 {
2722 new_id &= 0xFFF;
2723 int32_t shft = guysbuf[new_id].attributes[1];
2724 byte is=((enemy*)guys.spr(guys.Count()-1))->item_set;
2725 enemy *e = new esLanmola((zfix)x,(zfix)y,new_id+0x1000,0);
2726
2727 if(!guys.add(e))
2728 {
2729 al_trace("Lanmola segment 1 could not be created!\n");
2730 guys.del(guys.Count()-1);
2731 return 0;
2732 }
2733 e->x = x;
2734 e->y = y;
2735
2736
2737
2738 for(int32_t i=1; i<zc_max(1,zc_min(253,guysbuf[new_id&0xFFF].attributes[0])); i++)
2739 {
2740 enemy *e2 = new esLanmola((zfix)x,(zfix)y,new_id+0x2000,-(i<<shft));
2741 if(!guys.add(e2))
2742 {
2743 al_trace("Lanmola segment %d could not be created!\n",i+1);
2744
2745 for(int32_t j=0; j<i+1; j++)
2746 guys.del(guys.Count()-1);
2747
2748 return 0;
2749 }
2750 e2->x = x;
2751 e2->y = y;
2752
2753 ((enemy*)guys.spr(guys.Count()-1))->item_set=is;
2754
2755 }
2756 }
2757 break;
2758
2759 case eeMANHAN:
2760 new_id &= 0xFFF;
2761
2762 for(int32_t i=0; i<((!(guysbuf[new_id].attributes[1]))?4:8); i++)
2763 {
2764 if(!guys.add(new esManhandla((zfix)x,(zfix)y,new_id+0x1000,i)))
2765 {
2766 al_trace("Manhandla head %d could not be created!\n",i+1);
2767
2768 for(int32_t j=0; j<i+1; j++)
2769 {
2770 guys.del(guys.Count()-1);
2771 }
2772
2773 return 0;
2774 }
2775
2776
2777 ((enemy*)guys.spr(guys.Count()-1))->frate=guysbuf[new_id].attributes[0];
2778 }
2779
2780 break;
2781
2782 case eeGLEEOK:
2783 {
2784 /*
2785 new_id &= 0xFFF;
2786 int32_t head_cnt = zc_max(1,zc_min(254,guysbuf[new_id&0xFFF].attributes[0]));
2787 Z_scripterrlog("Gleeok head count is %d\n",head_cnt);
2788 for(int32_t i=0; i<head_cnt; i++)
2789 {
2790 //enemy *e = new esGleeok(x,y,new_id+0x1000,clk,gleeok);
2791 if(!guys.add(new esGleeok((zfix)x,(zfix)y,new_id+0x1000,c, gleeok)))
2792 {
2793 al_trace("Gleeok head %d could not be created!\n",i+1);
2794
2795 for(int32_t j=0; j<i+1; j++)
2796 {
2797 guys.del(guys.Count()-1);
2798 }
2799
2800 break;
2801 }
2802
2803 c-=guysbuf[new_id].misc4;
2804 */
2805
2806 // }
2807 }
2808 break;
2809
2810
2811 case eePATRA:
2812 {
2813 new_id &= 0xFFF;
2814 int32_t outeyes = 0;
2815 ptra = new ePatraBS((zfix)x,(zfix)y,id,clk);
2816
2817 for(int32_t i=0; i<zc_min(254,guysbuf[new_id&0xFFF].attributes[0]); i++)
2818 {
2819 if(!((guysbuf[new_id].attributes[9] &&get_qr(qr_HARDCODED_BS_PATRA))?guys.add(new esPatraBS((zfix)x,(zfix)y,new_id+0x1000,i,ptra)):guys.add(new esPatra((zfix)x,(zfix)y,new_id+0x1000,i,ptra))))
2820 {
2821 al_trace("Patra outer eye %d could not be created!\n",i+1);
2822
2823 for(int32_t j=0; j<i+1; j++)
2824 guys.del(guys.Count()-1);
2825
2826 return 0;
2827 }
2828 else
2829 outeyes++;
2830
2831
2832 }
2833
2834 for(int32_t i=0; i<zc_min(254,guysbuf[new_id&0xFFF].attributes[1]); i++)
2835 {
2836 if(!guys.add(new esPatra((zfix)x,(zfix)y,new_id+0x1000,i,ptra)))
2837 {
2838 al_trace("Patra inner eye %d could not be created!\n",i+1);
2839
2840 for(int32_t j=0; j<i+1+zc_min(254,outeyes); j++)
2841 guys.del(guys.Count()-1);
2842
2843 return 0;
2844 }
2845
2846
2847 }
2848 delete ptra;
2849 break;
2850 }
2851 }
2852
2853
2854
2855 ((enemy*)guys.spr(guys.Count()-1))->count_enemy = true;
2856 ((enemy*)guys.spr(guys.Count()-1))->stunclk = delay_timer;
2857 ((enemy*)guys.spr(guys.Count()-1))->dir = this->dir;
2858 ((enemy*)guys.spr(guys.Count()-1))->scale = this->scale;
2859 ((enemy*)guys.spr(guys.Count()-1))->angular = this->angular;
2860 ((enemy*)guys.spr(guys.Count()-1))->angle = this->angle;
2861 ((enemy*)guys.spr(guys.Count()-1))->rotation = this->rotation;
2862 ((enemy*)guys.spr(guys.Count()-1))->itemguy = this->itemguy;
2863 ((enemy*)guys.spr(guys.Count()-1))->leader = this->leader;
2864 ((enemy*)guys.spr(guys.Count()-1))->hclk = delay_timer;
2865 ((enemy*)guys.spr(guys.Count()-1))->script_spawned = this->script_spawned;
2866 ((enemy*)guys.spr(guys.Count()-1))->script_UID = this->script_UID;
2867 ((enemy*)guys.spr(guys.Count()-1))->sclk = 0;
2868
2869
2870 item_set = 0; //Do not make a drop.
2871
2872 switch(effect_type)
2873 {
2874 case -7:
2875 {
2876 weapon *w = new weapon(x,y-fakez,z,wBomb,0,wdp,0,-1,getUID(),false, 0);
2877 Lwpns.add(w);
2878 break;
2879 }
2880 case -6:
2881 {
2882 weapon *w = new weapon(x,y-fakez,z,wSBomb,0,wdp,0,-1,getUID(),false, 0);
2883 Lwpns.add(w);
2884 break;
2885 }
2886 case -5:
2887 {
2888 weapon *w = new weapon(x,y-fakez,z,wBomb,effect_type,0,0,Hero.getUID(), txsz, tysz);
2889 Lwpns.add(w);
2890 break;
2891 }
2892 case -4:
2893 {
2894 weapon *w = new weapon(x,y-fakez,z,wSBomb,effect_type,0,0,Hero.getUID(), txsz, tysz);
2895 Lwpns.add(w);
2896 break;
2897 }
2898 case -3: explode(1); break;
2899 case -2: explode(2); break;
2900 case -1: explode(0); break;
2901 case 0: break;
2902
2903 default:
2904 {
2905 //Dummy weapon function
2906 if ( effect_type > 255 ) effect_type = 0; //Sanity bound the sprite ID.
2907 weapon *w = new weapon(x,y-fakez,z,wSSparkle,effect_type,0,0,Hero.getUID(), txsz, tysz,0,0,0,0,0,0,0);
2908 Lwpns.add(w);
2909 break;
2910 }
2911 }
2912
2913
2914 yofs = -32768;
2915 switch(guysbuf[new_id&0xFFF].family)
2916 {
2917 case eeGLEEOK:
2918 {
2919 Z_scripterrlog("Replacing a gleeok.\n");
2920 enemy *tempenemy = (enemy *) guys.getByUID(parentCore);
2921 hp = -999;
2922 tempenemy->hp = -999;
2923 break;
2924
2925 }
2926 default:
2927 hp = -1000; break;
2928 }
2929 ++game->guys[(currmap*MAPSCRSNORMAL)+currscr];
2930 return 1;
2931
2932 }
2933 case edSPLIT:
2934 {
2935 for ( int32_t q = 0; q < dmisc4; q++ )
2936 {
2937 addenemy(
2938 //ex,ey,
2939 x,y,
2940 dmisc3+0x1000,-15);
2941
2942 }
2943 item_set = 0; //Do not make a drop.
2944 hp = -1000;
2945 return -1;
2946
2947 }
2948 case edSUMMON:
2949 {
2950 int32_t summon_count = (zc_oldrand()%dmisc4)+1;
2951 for ( int32_t q = 0; q < summon_count; q++ )
2952 {
2953 int32_t x2=16*((zc_oldrand()%12)+2);
2954 int32_t y2=16*((zc_oldrand()%7)+2);
2955 addenemy(
2956 x2,y2,
2957 dmisc3+0x1000,-15);
2958
2959 }
2960 sfx(get_qr(qr_MORESOUNDS) ? WAV_ZN1SUMMON : WAV_FIRE,pan(int32_t(x)));
2961 return -1;
2962
2963 }
2964
2965 case edEXPLODESMALL:
2966 {
2967 weapon *ew=new weapon(x,y-fakez,z, ewBomb, 0, dmisc4, dir,-1,getUID(),false);
2968 Ewpns.add(ew);
2969 item_set = 0; //Should we make a drop?
2970 hp = -1000;
2971 return -1;
2972 }
2973
2974
2975 case edEXPLODEHARMLESS:
2976 {
2977 weapon *ew=new weapon(x,y-fakez,z, ewSBomb, 0, dmisc4, dir,-1,getUID(),false);
2978 Ewpns.add(ew);
2979 ew->hyofs = -32768;
2980 item_set = 0; //Should we make a drop?
2981 hp = -1000;
2982 return -1;
2983 }
2984
2985
2986 case edEXPLODELARGE:
2987 {
2988 weapon *ew=new weapon(x,y-fakez,z, ewSBomb, 0, dmisc4, dir,-1,getUID(),false);
2989 Ewpns.add(ew);
2990
2991 hp = -1000;
2992 return -1;
2993 }
2994
2995
2996 case edTRIGGERSECRETS:
2997 {
2998 hidden_entrance(0, true, false, -4);
2999 return -1;
3000 }
3001
3002 case edSTUNORCHINK:
3003
3/4
✓ Branch 0 taken 1119 times.
✓ Branch 1 taken 1056 times.
✓ Branch 2 taken 1119 times.
✗ Branch 3 not taken.
3701 if (stunclk && get_qr(qr_NO_STUNLOCK))
3004 {
3005 sfx(WAV_CHINK,pan(int32_t(x)));
3006 return 1;
3007 }
3008
2/2
✓ Branch 0 taken 649 times.
✓ Branch 1 taken 1526 times.
2175 else if(*power <= 0)
3009 {
3010 649 sfx(WAV_CHINK,pan(int32_t(x)));
3011 649 return 1;
3012 }
3013 [[fallthrough]];
3014
3015 case edSTUNORIGNORE:
3016
3/4
✓ Branch 0 taken 1952 times.
✓ Branch 1 taken 1505 times.
✓ Branch 2 taken 1952 times.
✗ Branch 3 not taken.
5959 if (stunclk && get_qr(qr_NO_STUNLOCK))
3017 {
3018 sfx(WAV_CHINK,pan(int32_t(x)));
3019 return 1;
3020 }
3021
2/2
✓ Branch 0 taken 955 times.
✓ Branch 1 taken 2502 times.
3457 else if(*power <= 0)
3022 955 return 0;
3023 [[fallthrough]];
3024
3025 case edSTUNONLY:
3026
7/10
✓ Branch 0 taken 4364 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4364 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4364 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 3817 times.
✓ Branch 7 taken 547 times.
✓ Branch 8 taken 4043 times.
✓ Branch 9 taken 321 times.
4364 if((wpnId==wFire || wpnId==wBomb || wpnId==wSBomb || wpnId==wHookshot || wpnId==wSword) && stunclk>=159)
3027 {
3028 // Z_message("enemy::defend(), edSTUNONLY found a weapon of type FIRE, BOMB, SBOMB, HOOKSHOT, or SWORD:, with wpnId: \n", wpnId);
3029 321 return 1;
3030 }
3031
3/4
✓ Branch 0 taken 3118 times.
✓ Branch 1 taken 925 times.
✓ Branch 2 taken 3118 times.
✗ Branch 3 not taken.
4043 if (stunclk && get_qr(qr_NO_STUNLOCK))
3032 {
3033 sfx(WAV_CHINK,pan(int32_t(x)));
3034 return 1;
3035 }
3036 else
3037 {
3038 4043 stunclk=160;
3039 4043 sfx(WAV_EHIT,pan(int32_t(x)));
3040
3041 4043 return 1;
3042 }
3043
3044 case edCHINKL1:
3045 if(*power >= 1*game->get_hero_dmgmult()) break;
3046 [[fallthrough]];
3047 case edCHINKL2:
3048
2/2
✓ Branch 0 taken 52 times.
✓ Branch 1 taken 61 times.
113 if(*power >= 2*game->get_hero_dmgmult()) break;
3049 [[fallthrough]];
3050 case edCHINKL4:
3051
2/2
✓ Branch 0 taken 80 times.
✓ Branch 1 taken 110 times.
190 if(*power >= 4*game->get_hero_dmgmult()) break;
3052 [[fallthrough]];
3053 case edCHINKL6:
3054
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 111 times.
111 if(*power >= 6*game->get_hero_dmgmult()) break;
3055 [[fallthrough]];
3056 case edCHINKL8:
3057
2/2
✓ Branch 0 taken 43 times.
✓ Branch 1 taken 111 times.
154 if(*power >= 8*game->get_hero_dmgmult()) break;
3058 [[fallthrough]];
3059 case edCHINKL10:
3060
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 111 times.
111 if(*power >= 10*game->get_hero_dmgmult()) break;
3061 [[fallthrough]];
3062 case edCHINK:
3063 1041 sfx(WAV_CHINK,pan(int32_t(x)));
3064 1041 return 1;
3065
3066 case edIGNOREL1:
3067 if(*power > 0) break;
3068 [[fallthrough]];
3069
3070 case edIGNORE:
3071 17324 return 0;
3072
3073 case ed1HKO:
3074 492 *power = hp;
3075 492 return -2;
3076
3077 case ed2x:
3078 {
3079
1/2
✓ Branch 0 taken 71 times.
✗ Branch 1 not taken.
71 *power = zc_max(1,*power*2);
3080 //int32_t pow = *power;
3081 //*power = vbound((pow*2),0,214747);
3082 71 return -1;
3083 }
3084 case ed3x:
3085 {
3086 *power = zc_max(1,*power*3);
3087 //int32_t pow = *power;
3088 //*power = vbound((pow*3),0,214747);
3089 return -1;
3090 }
3091
3092 case ed4x:
3093 {
3094 *power = zc_max(1,*power*4);
3095 //int32_t pow = *power;
3096 //*power = vbound((pow*4),0,214747);
3097 return -1;
3098 }
3099
3100
3101 case edHEAL:
3102 { //Probably needs its own function, or routine in the damage functuon to heal if power is negative.
3103 //int32_t pow = *power;
3104 //*power = vbound((pow*-1),0,214747);
3105 //break;
3106
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 158 times.
158 *power = zc_min(0,*power*-1);
3107 158 return -1;
3108 }
3109 /*
3110 case edLEVELDAMAGE:
3111 {
3112 int32_t pow = *power;
3113 int32_t lvl = *level;
3114 *power = vbound((pow*lvl),0,214747);
3115 break;
3116 }
3117 case edLEVELREDUCTION:
3118 {
3119 int32_t pow = *power;
3120 int32_t lvl = *level;
3121 *power = vbound((pow/lvl),0,214747);
3122 break;
3123 }
3124 */
3125
3126 case edQUARTDAMAGE:
3127
2/2
✓ Branch 0 taken 102 times.
✓ Branch 1 taken 3 times.
105 *power = zc_max(1,*power/2);
3128
3129 [[fallthrough]];
3130 case edHALFDAMAGE:
3131
2/2
✓ Branch 0 taken 832 times.
✓ Branch 1 taken 156 times.
988 *power = zc_max(1,*power/2);
3132 988 break;
3133
3134 case edSWITCH:
3135 {
3136
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(Hero.switchhookclk) return 0; //Already switching!
3137
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 switch(family)
3138 {
3139 case eeAQUA: case eeMOLD: case eeDONGO: case eeMANHAN: case eeGLEEOK:
3140 case eeDIG: case eeGHOMA: case eeLANM: case eePATRA: case eeGANON:
3141 return 0;
3142 }
3143 4 hooked_combopos = -1;
3144 4 hooked_layerbits = 0;
3145 4 switching_object = this;
3146 4 switch_hooked = true;
3147 4 Hero.doSwitchHook(game->get_switchhookstyle());
3148
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(QMisc.miscsfx[sfxSWITCHED])
3149 sfx(QMisc.miscsfx[sfxSWITCHED],int32_t(x));
3150 4 return 1;
3151 }
3152
3153 case 0:
3154 {
3155
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 93064 times.
93064 if(edef == edefSwitchHook)
3156 return -1;
3157
6/6
✓ Branch 0 taken 19532 times.
✓ Branch 1 taken 73532 times.
✓ Branch 2 taken 58 times.
✓ Branch 3 taken 19474 times.
✓ Branch 4 taken 32 times.
✓ Branch 5 taken 26 times.
93064 if (stunclk && get_qr(qr_NO_STUNLOCK) && *power == 0)
3158 {
3159 26 sfx(WAV_CHINK,pan(int32_t(x)));
3160 26 return 1;
3161 }
3162
3163 }
3164 93038 }
3165
3166 94201 return -1;
3167 125858 }
3168
3169 125858 int32_t enemy::defendNewInt(int32_t wpnId, int32_t *power, int32_t edef, byte unblockable, weapon* w)
3170 {
3171
1/2
✓ Branch 0 taken 125858 times.
✗ Branch 1 not taken.
125858 int wuid = w?w->getUID():0;
3172
1/2
✓ Branch 0 taken 125858 times.
✗ Branch 1 not taken.
125858 bool fakeweap = (w && !Lwpns.getByUID(wuid));
3173
3174
1/2
✓ Branch 0 taken 125858 times.
✗ Branch 1 not taken.
125858 if(fakeweap)
3175 Lwpns.add(w);
3176 125858 std::vector<int32_t> &ev = FFCore.eventData;
3177 125858 ev.clear();
3178 125858 ev.push_back(*power*10000);
3179 125858 ev.push_back(edef*10000);
3180 125858 ev.push_back(unblockable*10000);
3181 125858 ev.push_back(wpnId*10000);
3182 125858 ev.push_back(0);
3183 125858 ev.push_back(getUID());
3184 125858 ev.push_back(wuid);
3185
3186 125858 throwGenScriptEvent(GENSCR_EVENT_ENEMY_HIT1);
3187 125858 *power = ev[0]/10000;
3188 125858 edef = ev[1]/10000;
3189 125858 unblockable = byte(ev[2]/10000);
3190 125858 wpnId = ev[3] / 10000;
3191 125858 bool nullify = ev[4]!=0;
3192 125858 ev.clear();
3193 125858 int ret = 0;
3194
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 125858 times.
125858 if(!nullify)
3195 {
3196 125858 ret = defendNew(wpnId, power, edef, unblockable);
3197
2/2
✓ Branch 0 taken 32790 times.
✓ Branch 1 taken 93068 times.
125858 if(ret == -1)
3198 {
3199 93068 ev.push_back(*power*10000);
3200 93068 ev.push_back(edef*10000);
3201 93068 ev.push_back(unblockable*10000);
3202 93068 ev.push_back(wpnId*10000);
3203 93068 ev.push_back(0);
3204 93068 ev.push_back(getUID());
3205
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 93068 times.
93068 ev.push_back(w?w->getUID():0);
3206
3207 93068 throwGenScriptEvent(GENSCR_EVENT_ENEMY_HIT2);
3208 93068 *power = ev[0]/10000;
3209 93068 nullify = ev[4]!=0;
3210 93068 ev.clear();
3211 93068 }
3212 125858 }
3213
1/2
✓ Branch 0 taken 125858 times.
✗ Branch 1 not taken.
125858 if(fakeweap)
3214 Lwpns.remove(w);
3215
3216
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 125858 times.
125858 return nullify ? 0 : ret;
3217 }
3218
3219 99055 int32_t enemy::defenditemclassNew(int32_t wpnId, int32_t *power, weapon *w, weapon* realweap)
3220 {
3221
2/2
✓ Branch 0 taken 98478 times.
✓ Branch 1 taken 577 times.
99055 if(!realweap) realweap = w;
3222 99055 int32_t wid = getWeaponID(w);
3223
3224 99055 int32_t edef = resolveEnemyDefence(w);
3225
2/2
✓ Branch 0 taken 5832 times.
✓ Branch 1 taken 93223 times.
99055 if(QHeader.zelda_version > 0x250)
3226 5832 return defendNewInt(wid, power, edef, w->unblockable, realweap);
3227
2/3
✓ Branch 0 taken 993 times.
✓ Branch 1 taken 92230 times.
✗ Branch 2 not taken.
93223 switch(wid)
3228 {
3229 case wScript1: case wScript2: case wScript3: case wScript4: case wScript5:
3230 case wScript6: case wScript7: case wScript8: case wScript9: case wScript10:
3231 993 return defend(wpnId, power, edefSCRIPT);
3232
3233 case wWhistle:
3234 return -1;
3235
3236 default:
3237 92230 return defendNewInt(wid, power, edef, w->unblockable, realweap);
3238 }
3239 99055 }
3240
3241
3242 // Check defenses without actually acting on them.
3243 27402 bool enemy::candamage(int32_t power, int32_t edef, byte unblockable)
3244 {
3245
4/10
✓ Branch 0 taken 15409 times.
✓ Branch 1 taken 11050 times.
✓ Branch 2 taken 469 times.
✓ Branch 3 taken 474 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
27402 switch(defense[edef])
3246 {
3247 case edSTUNONLY:
3248 474 return false;
3249 case edSTUNORCHINK:
3250 case edCHINK:
3251 15409 return unblockable&WPNUNB_BLOCK;
3252 case edSTUNORIGNORE:
3253 case edIGNORE:
3254 11050 return unblockable&WPNUNB_IGNR;
3255
3256 case edIGNOREL1:
3257 return (unblockable&WPNUNB_IGNR) || power >= 1*game->get_hero_dmgmult();
3258 case edCHINKL1:
3259 return (unblockable&WPNUNB_BLOCK) || power >= 1*game->get_hero_dmgmult();
3260
3261 case edCHINKL2:
3262 return (unblockable&WPNUNB_BLOCK) || power >= 2*game->get_hero_dmgmult();
3263
3264 case edCHINKL4:
3265 return (unblockable&WPNUNB_BLOCK) || power >= 4*game->get_hero_dmgmult();
3266
3267 case edCHINKL6:
3268 return (unblockable&WPNUNB_BLOCK) || power >= 6*game->get_hero_dmgmult();
3269
3270 case edCHINKL8:
3271 return (unblockable&WPNUNB_BLOCK) || power >= 8*game->get_hero_dmgmult();
3272 }
3273
3274 469 return true;
3275 27402 }
3276
3277 // Do we do damage?
3278 // 0: takehit returns 0
3279 // 1: takehit returns 1
3280 // -1: do damage
3281 993 int32_t enemy::defend(int32_t wpnId, int32_t *power, int32_t edef)
3282 {
3283
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 993 times.
993 if(shieldCanBlock)
3284 {
3285 switch(defense[edef])
3286 {
3287 case edIGNORE:
3288 return 0;
3289 case edIGNOREL1:
3290 case edSTUNORIGNORE:
3291 if(*power <= 0)
3292 return 0;
3293 }
3294
3295 sfx(WAV_CHINK,pan(int32_t(x)));
3296 return 1;
3297 }
3298
3299
3/22
✓ Branch 0 taken 186 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 800 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✓ Branch 21 taken 7 times.
993 switch(defense[edef])
3300 {
3301 case edSTUNORCHINK:
3302 if(*power <= 0)
3303 {
3304 sfx(WAV_CHINK,pan(int32_t(x)));
3305 return 1;
3306 }
3307
3308 [[fallthrough]];
3309 case edSTUNORIGNORE:
3310 if(*power <= 0)
3311 return 0;
3312
3313 [[fallthrough]];
3314 case edSTUNONLY:
3315 if((wpnId==wFire || wpnId==wBomb || wpnId==wSBomb || wpnId==wHookshot || wpnId==wSword) && stunclk>=159)
3316 return 1;
3317
3318 stunclk=160;
3319 sfx(WAV_EHIT,pan(int32_t(x)));
3320 return 1;
3321
3322 case edFREEZE:
3323 frozenclock=-1;
3324 //sfx(WAV_FREEZE,pan(int32_t(x)));
3325 return 1;
3326
3327 case edCHINKL1:
3328 if(*power >= 1*game->get_hero_dmgmult()) break;
3329 [[fallthrough]];
3330 case edCHINKL2:
3331 if(*power >= 2*game->get_hero_dmgmult()) break;
3332 [[fallthrough]];
3333 case edCHINKL4:
3334 if(*power >= 4*game->get_hero_dmgmult()) break;
3335 [[fallthrough]];
3336 case edCHINKL6:
3337 if(*power >= 6*game->get_hero_dmgmult()) break;
3338 [[fallthrough]];
3339 case edCHINKL8:
3340 if(*power >= 8*game->get_hero_dmgmult()) break;
3341 [[fallthrough]];
3342 case edCHINKL10:
3343 if(*power >= 10*game->get_hero_dmgmult()) break;
3344 [[fallthrough]];
3345 case edCHINK:
3346 sfx(WAV_CHINK,pan(int32_t(x)));
3347 return 1;
3348 case edTRIGGERSECRETS:
3349 hidden_entrance(0, true, false, -4);
3350 break;
3351
3352 case edIGNOREL1:
3353 if(*power > 0) break;
3354 [[fallthrough]];
3355 case edIGNORE:
3356 800 return 0;
3357
3358 case ed1HKO:
3359 *power = hp;
3360 return -2;
3361
3362 case ed2x:
3363 {
3364 *power = zc_max(1,*power*2);
3365 //int32_t pow = *power;
3366 //*power = vbound((pow*2),0,214747);
3367 return -1;
3368 }
3369 case ed3x:
3370 {
3371 *power = zc_max(1,*power*3);
3372 //int32_t pow = *power;
3373 //*power = vbound((pow*3),0,214747);
3374 return -1;
3375 }
3376
3377 case ed4x:
3378 {
3379 *power = zc_max(1,*power*4);
3380 //int32_t pow = *power;
3381 //*power = vbound((pow*4),0,214747);
3382 return -1;
3383 }
3384
3385
3386 case edHEAL:
3387 { //Probably needs its own function, or routine in the damage functuon to heal if power is negative.
3388 //int32_t pow = *power;
3389 //*power = vbound((pow*-1),0,214747);
3390 //break;
3391 *power = zc_min(0,*power*-1);
3392 return -1;
3393 }
3394 /*
3395 case edLEVELDAMAGE:
3396 {
3397 int32_t pow = *power;
3398 int32_t lvl = *level;
3399 *power = vbound((pow*lvl),0,214747);
3400 break;
3401 }
3402 case edLEVELREDUCTION:
3403 {
3404 int32_t pow = *power;
3405 int32_t lvl = *level;
3406 *power = vbound((pow/lvl),0,214747);
3407 break;
3408 }
3409 */
3410
3411
3412 case edQUARTDAMAGE:
3413
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
7 *power = zc_max(1,*power/2);
3414
3415 [[fallthrough]];
3416 case edHALFDAMAGE:
3417
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
7 *power = zc_max(1,*power/2);
3418 7 break;
3419 }
3420
3421 193 return -1;
3422 993 }
3423
3424 // Defend against a particular item class.
3425 int32_t enemy::defenditemclass(int32_t wpnId, int32_t *power)
3426 {
3427 int32_t def=-1;
3428
3429 switch(wpnId)
3430 {
3431 // These first 2 are only used by Gohma... enemy::takehit() has complicated stun-calculation code for these.
3432 case wBrang:
3433 def = defend(wpnId, power, edefBRANG);
3434 break;
3435
3436 case wHookshot:
3437 def = defend(wpnId, power, edefHOOKSHOT);
3438 break;
3439
3440 // Anyway...
3441 case wBomb:
3442 def = defend(wpnId, power, edefBOMB);
3443 break;
3444
3445 case wSBomb:
3446 def = defend(wpnId, power, edefSBOMB);
3447 break;
3448
3449 case wArrow:
3450 def = defend(wpnId, power, edefARROW);
3451 break;
3452
3453 case wFire:
3454 def = defend(wpnId, power, edefFIRE);
3455 break;
3456
3457 case wWand:
3458 def = defend(wpnId, power, edefWAND);
3459 break;
3460
3461 case wMagic:
3462 def = defend(wpnId, power, edefMAGIC);
3463 break;
3464
3465 case wHammer:
3466 def = defend(wpnId, power, edefHAMMER);
3467 break;
3468
3469 case wSword:
3470 def = defend(wpnId, power, edefSWORD);
3471 break;
3472
3473 case wBeam:
3474 def = defend(wpnId, power, edefBEAM);
3475 break;
3476
3477 case wRefBeam:
3478 def = defend(wpnId, power, edefREFBEAM);
3479 break;
3480
3481 case wRefMagic:
3482 def = defend(wpnId, power, edefREFMAGIC);
3483 break;
3484
3485 case wRefFireball:
3486 def = defend(wpnId, power, edefREFBALL);
3487 break;
3488
3489 case wRefRock:
3490 def = defend(wpnId, power, edefREFROCK);
3491 break;
3492
3493 case wStomp:
3494 def = defend(wpnId, power, edefSTOMP);
3495 break;
3496
3497 case wCByrna:
3498 def = defend(wpnId, power, edefBYRNA);
3499 break;
3500
3501 case wScript1:
3502 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT01);
3503 else def = defend(wpnId, power, edefSCRIPT);
3504 break;
3505
3506 case wScript2:
3507 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT02);
3508 else def = defend(wpnId, power, edefSCRIPT);
3509 break;
3510
3511 case wScript3:
3512 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT03);
3513 else def = defend(wpnId, power, edefSCRIPT);
3514 break;
3515
3516 case wScript4:
3517 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT04);
3518 else def = defend(wpnId, power, edefSCRIPT);
3519 break;
3520
3521 case wScript5:
3522 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT05);
3523 else def = defend(wpnId, power, edefSCRIPT);
3524 break;
3525
3526 case wScript6:
3527 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT06);
3528 else def = defend(wpnId, power, edefSCRIPT);
3529 break;
3530
3531 case wScript7:
3532 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT07);
3533 else def = defend(wpnId, power, edefSCRIPT);
3534 break;
3535
3536 case wScript8:
3537 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT08);
3538 else def = defend(wpnId, power, edefSCRIPT);
3539 break;
3540
3541 case wScript9:
3542 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT09);
3543 else def = defend(wpnId, power, edefSCRIPT);
3544 break;
3545
3546 case wScript10:
3547 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT10);
3548 else def = defend(wpnId, power, edefSCRIPT);
3549 break;
3550
3551 case wWhistle:
3552 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefWhistle);
3553 else break;
3554 break;
3555
3556 case wRefArrow:
3557 def = defend(wpnId, power, edefREFARROW);
3558 break;
3559 case wRefFire:
3560 def = defend(wpnId, power, edefREFFIRE);
3561 break;
3562 case wRefFire2:
3563 def = defend(wpnId, power, edefREFFIRE2);
3564 break;
3565
3566 //!ZoriaRPG : We need some special cases here, to ensure that old script defs don;t break.
3567 //Probably best to do this from the qest file, loading the values of Script(generic) into each
3568 //of the ten if the quest version is lower than N.
3569 //Either that, or we need a boolean flag to set int32_t he enemy editor, or by ZScript that changes this behaviour.
3570 //such as bool UseSeparatedScriptDefences. hah.
3571 default:
3572 //if(wpnId>=wScript1 && wpnId<=wScript10)
3573 // {
3574 // def = defend(wpnId, power, edefSCRIPT);
3575 // }
3576 // }
3577
3578 break;
3579 }
3580
3581 return def;
3582 }
3583
3584 // take damage or ignore it
3585 // -1: damage (if any) dealt
3586 // 1: blocked
3587 // 0: weapon passes through unhindered
3588 264467 int32_t enemy::takehit(weapon *w, weapon* realweap)
3589 {
3590
2/4
✓ Branch 0 taken 264467 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 264467 times.
264467 if(fallclk||drownclk) return 0;
3591
2/2
✓ Branch 0 taken 69393 times.
✓ Branch 1 taken 195074 times.
264467 if(!realweap) realweap = w;
3592 264467 int32_t wpnId = w->id;
3593 264467 int32_t power = w->power;
3594 264467 int32_t wpnx = w->x;
3595 264467 int32_t wpny = w->y;
3596 264467 int32_t enemyHitWeapon = w->parentitem;
3597 int32_t wpnDir;
3598 264467 int32_t parent_item = w->parentitem;
3599
3600
2/2
✓ Branch 0 taken 264352 times.
✓ Branch 1 taken 115 times.
264467 if ( w->useweapon > 0 /*&& wpnId != wWhistle*/ )
3601 {
3602 115 wpnId = w->useweapon;
3603 115 }
3604
3605 // If it's a boomerang that just bounced, use the opposite direction;
3606 // otherwise, it might bypass a shield. This probably won't handle
3607 // every case correctly, but it's better than having shields simply
3608 // not work against boomerangs.
3609
8/8
✓ Branch 0 taken 25075 times.
✓ Branch 1 taken 239392 times.
✓ Branch 2 taken 15580 times.
✓ Branch 3 taken 9495 times.
✓ Branch 4 taken 14362 times.
✓ Branch 5 taken 1218 times.
✓ Branch 6 taken 3306 times.
✓ Branch 7 taken 11056 times.
264467 if(w->id==wBrang && w->misc==1 && w->clk2>=256 && w->clk2<264)
3610 11056 wpnDir = oppositeDir[w->dir];
3611 else
3612 253411 wpnDir = w->dir;
3613
3614
5/8
✓ Branch 0 taken 264467 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 264467 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 264467 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 8172 times.
✓ Branch 7 taken 271925 times.
264467 if(dying || clk<0 || hclk>0 || superman)
3615 8172 return 0;
3616
3617 //Prevent boomerang from writing to hitby[] for more than one frame.
3618 //This also prevents stunlock.
3619 //if ( stunclk > 0 ) return 0;
3620 //this needs a rule for boomerangs that cannot stunlock!
3621 //further, bouncing weapons should probably SFX_CHINK and bounce here.
3622 //sigh.
3623
3624 271925 int32_t ret = -1;
3625
3626 // This obscure quest rule...
3627
5/6
✓ Branch 0 taken 91703 times.
✓ Branch 1 taken 180222 times.
✓ Branch 2 taken 88200 times.
✓ Branch 3 taken 3503 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 88200 times.
271925 if(get_qr(qr_BOMBDARKNUTFIX) && (wpnId==wBomb || wpnId==wSBomb))
3628 {
3629 double _MSVC2022_tmp1, _MSVC2022_tmp2;
3630 3503 double ddir=atan2_MSVC2022_FIX(double(wpny-y),double(x-wpnx));
3631 3503 wpnDir=zc_oldrand()&3;
3632
3633
4/4
✓ Branch 0 taken 467 times.
✓ Branch 1 taken 3036 times.
✓ Branch 2 taken 278 times.
✓ Branch 3 taken 189 times.
3503 if((ddir<=(((-1)*PI)/4))&&(ddir>(((-3)*PI)/4)))
3634 {
3635 189 wpnDir=down;
3636 189 }
3637
4/4
✓ Branch 0 taken 563 times.
✓ Branch 1 taken 2751 times.
✓ Branch 2 taken 278 times.
✓ Branch 3 taken 285 times.
3314 else if((ddir<=(((1)*PI)/4))&&(ddir>(((-1)*PI)/4)))
3638 {
3639 285 wpnDir=right;
3640 285 }
3641
4/4
✓ Branch 0 taken 2342 times.
✓ Branch 1 taken 687 times.
✓ Branch 2 taken 278 times.
✓ Branch 3 taken 2064 times.
3029 else if((ddir<=(((3)*PI)/4))&&(ddir>(((1)*PI)/4)))
3642 {
3643 2064 wpnDir=up;
3644 2064 }
3645 else
3646 {
3647 965 wpnDir=left;
3648 }
3649 3503 }
3650
3651 271925 int32_t xdir = dir;
3652 271925 shieldCanBlock=false;
3653
3654
4/4
✓ Branch 0 taken 260645 times.
✓ Branch 1 taken 11280 times.
✓ Branch 2 taken 2767 times.
✓ Branch 3 taken 257878 times.
272653 if(!(w->unblockable&WPNUNB_BLOCK)&&((wpnId==wHookshot && hitshield(wpnx, wpny, xdir))
3655
6/6
✓ Branch 0 taken 18250 times.
✓ Branch 1 taken 15483 times.
✓ Branch 2 taken 26192 times.
✓ Branch 3 taken 247169 times.
✓ Branch 4 taken 58 times.
✓ Branch 5 taken 247111 times.
260645 || ((flags&guy_shield_front && wpnDir==(xdir^down)) || (flags&guy_shield_back && wpnDir==(xdir^up)) ||
3656
4/4
✓ Branch 0 taken 984 times.
✓ Branch 1 taken 246127 times.
✓ Branch 2 taken 728 times.
✓ Branch 3 taken 245399 times.
247111 (flags&guy_shield_left && wpnDir==(xdir^(xdir&2?right:left))) || (flags&guy_shield_right && wpnDir==(xdir^(dir&2?left:right)))))
3657 )
3658 // The hammer should already be dealt with by subclasses (Walker etc.)
3659 {
3660
10/10
✓ Branch 0 taken 864 times.
✓ Branch 1 taken 380 times.
✓ Branch 2 taken 29 times.
✓ Branch 3 taken 680 times.
✓ Branch 4 taken 5756 times.
✓ Branch 5 taken 338 times.
✓ Branch 6 taken 13 times.
✓ Branch 7 taken 11 times.
✓ Branch 8 taken 153 times.
✓ Branch 9 taken 1488 times.
46212 switch(wpnId)
3661 {
3662 // Weapons which shields protect against
3663 case wSword:
3664 case wWand:
3665
2/2
✓ Branch 0 taken 5754 times.
✓ Branch 1 taken 2 times.
5758 if(Hero.getCharging()>0)
3666 2 Hero.setAttackClk(Hero.getAttackClk()+1); //Cancel charging
3667
3668 [[fallthrough]];
3669 case wHookshot:
3670 case wHSHandle:
3671 case wBrang:
3672 6136 shieldCanBlock=true;
3673 6474 break;
3674
3675 case wBeam:
3676 case wRefBeam:
3677 // Mirror shielded enemies!
3678 #if 0
3679 if(false /*flags&guy_mirror*/ && !get_qr(qr_SWORDMIRROR))
3680 {
3681 if(wpnId>wEnemyWeapons)
3682 return 0;
3683
3684 sfx(WAV_CHINK,pan(int32_t(x)));
3685 return 1;
3686 }
3687
3688 #endif
3689
3690 [[fallthrough]];
3691 case wRefRock:
3692 case wRefFireball:
3693 case wMagic:
3694 #if 0
3695 if(false /*flags&guy_mirror*/ && (wpnId!=wRefRock || get_qr(qr_REFLECTROCKS)))
3696 {
3697 sfx(WAV_CHINK,pan(int32_t(x)));
3698 return 3;
3699 }
3700
3701 #endif
3702
3703
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 367 times.
367 if(wpnId>wEnemyWeapons)
3704 return 0;
3705
3706 [[fallthrough]];
3707 case wArrow:
3708 380 case wRefArrow:
3709 default:
3710 1868 shieldCanBlock=true;
3711 1868 break;
3712
3713 // Bombs
3714 case wSBomb:
3715 case wBomb:
3716
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
11 if (!get_qr(qr_TRUEFIXEDBOMBSHIELD)) goto hitclock;
3717 else if (!get_qr(qr_BOMBSPIERCESHIELD))
3718 {
3719 sfx(WAV_CHINK,pan(int32_t(x)));
3720 return 0;
3721 }
3722 else break;
3723
3724 // Weapons which ignore shields
3725 case wWhistle:
3726 case wHammer:
3727 153 break;
3728
3729 // Weapons which shouldn't be removed by shields
3730 case wLitBomb:
3731 case wLitSBomb:
3732 case wWind:
3733 case wPhantom:
3734 case wSSparkle:
3735 case wBait:
3736 864 return 0;
3737
3738 case wFire:
3739 case wRefFire:
3740 case wRefFire2:
3741 ;
3742 680 }
3743 8837 }
3744
3745
8/8
✓ Branch 0 taken 103171 times.
✓ Branch 1 taken 97398 times.
✓ Branch 2 taken 423 times.
✓ Branch 3 taken 270 times.
✓ Branch 4 taken 27402 times.
✓ Branch 5 taken 25029 times.
✓ Branch 6 taken 2767 times.
✓ Branch 7 taken 9056 times.
265516 switch(wpnId)
3746 {
3747 case wWhistle: //No longer completely ignore whistle weapons! -Z
3748 {
3749
3750
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 423 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
423 if ( ((itemsbuf[parent_item].flags & item_flag2) == 0) || ( parent_item == -1 ) ) //if the flag is set, or the weapon is scripted
3751 {
3752 423 return 0; break;
3753 }
3754 else
3755 {
3756 w->power = power = itemsbuf[parent_item].misc5;
3757
3758 int32_t def = defendNewInt(wpnId, &power, resolveEnemyDefence(w), w->unblockable, realweap);
3759
3760 if(def <= 0)
3761 {
3762 if ( def == -2 ) hp -= hp;
3763 else hp -= power;
3764 return def;
3765 }
3766 break;
3767 }
3768 break;
3769 }
3770
3771 case wPhantom:
3772 270 return 0;
3773
3774 case wLitBomb:
3775 case wLitSBomb:
3776 case wBait:
3777 case wWind:
3778 case wSSparkle:
3779 103171 return 0;
3780
3781 case wFSparkle:
3782
3783 // Only take sparkle damage if the sparkle's parent item is not
3784 // defended against.
3785
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27402 times.
27402 if(enemyHitWeapon > -1)
3786 {
3787 27402 int32_t p = 0;
3788 27402 int32_t f = itemsbuf[enemyHitWeapon].family;
3789
3790
1/4
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 27402 times.
27402 switch(f)
3791 {
3792 case itype_arrow:
3793 if(!candamage(p, edefARROW, w->unblockable)) return 0;
3794
3795 break;
3796
3797 case itype_cbyrna:
3798 if(!candamage(p, edefBYRNA, w->unblockable)) return 0;
3799
3800 break;
3801
3802 case itype_brang:
3803
2/2
✓ Branch 0 taken 469 times.
✓ Branch 1 taken 26933 times.
27402 if(!candamage(p, edefBRANG, w->unblockable)) return 0;
3804
3805 469 break;
3806
3807 default:
3808 return 0;
3809 }
3810 469 }
3811
3812 469 wpnId = wSword;
3813 469 power = game->get_hero_dmgmult()>>1;
3814 469 goto fsparkle;
3815 break;
3816
3817 case wBrang:
3818 {
3819 //int32_t def = defendNew(wpnId, &power, edefBRANG, w);
3820 25029 int32_t def = defendNewInt(wpnId, &power, resolveEnemyDefence(w), w->unblockable, realweap);
3821 //preventing stunlock might be best, here. -Z
3822
2/2
✓ Branch 0 taken 5471 times.
✓ Branch 1 taken 19558 times.
25029 if(def >= 0) return def;
3823
3824 // Not hurt by 0-damage weapons
3825
2/2
✓ Branch 0 taken 3184 times.
✓ Branch 1 taken 16374 times.
19558 if(!(flags & guy_bhit))
3826 {
3827 16374 stunclk=160;
3828
3829
3/4
✓ Branch 0 taken 16374 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1305 times.
✓ Branch 3 taken 15069 times.
16374 if(enemyHitWeapon>-1 ? itemsbuf[enemyHitWeapon].power : current_item_power(itype_brang))
3830 {
3831
1/2
✓ Branch 0 taken 1305 times.
✗ Branch 1 not taken.
1305 hp -= (enemyHitWeapon>-1 ? itemsbuf[enemyHitWeapon].power : current_item_power(itype_brang))*game->get_hero_dmgmult();
3832 1305 goto hitclock;
3833 }
3834
3835 15069 break;
3836 }
3837
3838
2/2
✓ Branch 0 taken 391 times.
✓ Branch 1 taken 2793 times.
3184 if(!power)
3839
1/2
✓ Branch 0 taken 2793 times.
✗ Branch 1 not taken.
2793 hp-=(enemyHitWeapon>-1 ? itemsbuf[enemyHitWeapon].fam_type : current_item(itype_brang))*game->get_hero_dmgmult();
3840 else
3841 391 hp-=power;
3842
3843 3184 goto hitclock;
3844 }
3845
3846 case wHookshot:
3847 {
3848 //int32_t def = defendNew(wpnId, &power, edefHOOKSHOT,w);
3849 2767 int32_t def = defendNewInt(wpnId, &power, resolveEnemyDefence(w), w->unblockable, realweap);
3850
3851
2/2
✓ Branch 0 taken 994 times.
✓ Branch 1 taken 1773 times.
2767 if(def >= 0) return def;
3852
3853
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1773 times.
1773 bool swgrab = switch_hooked || w->family_class == itype_switchhook;
3854
3/4
✓ Branch 0 taken 1773 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1625 times.
✓ Branch 3 taken 148 times.
1773 if(swgrab || !(flags & guy_bhit))
3855 {
3856
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1625 times.
1625 if(!swgrab)
3857 1625 stunclk=160;
3858
3859
3/4
✓ Branch 0 taken 1625 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 549 times.
✓ Branch 3 taken 1076 times.
1625 if(enemyHitWeapon>-1 ? itemsbuf[enemyHitWeapon].power : current_item_power(itype_hookshot))
3860 {
3861
1/2
✓ Branch 0 taken 549 times.
✗ Branch 1 not taken.
549 hp -= (enemyHitWeapon>-1 ? itemsbuf[enemyHitWeapon].power : current_item_power(itype_hookshot))*game->get_hero_dmgmult();
3862 549 goto hitclock;
3863 }
3864
3865 1076 break;
3866 }
3867
3868
3/4
✓ Branch 0 taken 45 times.
✓ Branch 1 taken 103 times.
✓ Branch 2 taken 103 times.
✗ Branch 3 not taken.
148 if(!power) hp-=(enemyHitWeapon>-1 ? itemsbuf[enemyHitWeapon].fam_type : current_item(itype_hookshot))*game->get_hero_dmgmult();
3869 else
3870 45 hp-=power;
3871
3872 148 goto hitclock;
3873 }
3874 break;
3875
3876 case wHSHandle:
3877 {
3878
3/4
✓ Branch 0 taken 9056 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 523 times.
✓ Branch 3 taken 8533 times.
9056 if(itemsbuf[enemyHitWeapon>-1 ? enemyHitWeapon : current_item_id(itype_hookshot)].flags & item_flag1)
3879 523 return 0;
3880
3881
3/4
✓ Branch 0 taken 6093 times.
✓ Branch 1 taken 2440 times.
✓ Branch 2 taken 2440 times.
✗ Branch 3 not taken.
8533 bool ignorehookshot = ((defense[edefHOOKSHOT] == edIGNORE) || ((defense[edefHOOKSHOT] == edIGNOREL1 || defense[edefHOOKSHOT] == edSTUNORIGNORE)
3882
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2440 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2440 && (enemyHitWeapon>-1 ? itemsbuf[enemyHitWeapon].power : current_item_power(itype_hookshot)) <= 0));
3883
3884 // Peahats, Darknuts, Aquamentuses, Pols Voices, Wizzrobes, Manhandlas
3885
6/8
✓ Branch 0 taken 2787 times.
✓ Branch 1 taken 5746 times.
✓ Branch 2 taken 2787 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2787 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 502 times.
✓ Branch 7 taken 2285 times.
10245 if(!(family==eePEAHAT || family==eeAQUA || family==eeMANHAN || (family==eeWIZZ && !ignorehookshot)
3886
6/6
✓ Branch 0 taken 3375 times.
✓ Branch 1 taken 2873 times.
✓ Branch 2 taken 1771 times.
✓ Branch 3 taken 3889 times.
✓ Branch 4 taken 1712 times.
✓ Branch 5 taken 2177 times.
2787 || (family==eeWALK && dmisc9==e9tPOLSVOICE) || (family==eeWALK && flags&(guy_shield_back|guy_shield_front|guy_shield_left|guy_shield_right))))
3887 2177 return 0;
3888
3889 12102 power = game->get_hero_dmgmult();
3890 12571 }
3891
3892 fsparkle:
3893
3894 [[fallthrough]];
3895 default:
3896 // Work out the defenses!
3897 {
3898 98477 int32_t def = defenditemclassNew(wpnId, &power, w, realweap);
3899
3900
2/2
✓ Branch 0 taken 26476 times.
✓ Branch 1 taken 72001 times.
98477 if(def >= 0)
3901 26476 return def;
3902
2/2
✓ Branch 0 taken 71541 times.
✓ Branch 1 taken 460 times.
72001 else if(def == -2)
3903 {
3904 460 ret = 0;
3905 460 }
3906 }
3907
3908
2/2
✓ Branch 0 taken 71999 times.
✓ Branch 1 taken 2 times.
144002 if(!power)
3909 {
3910
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(flags & guy_bhit)
3911 2 hp-=1;
3912 else
3913 {
3914 // Don't make a long chain of 'stun' hits
3915 if((wpnId==wFire || wpnId==wBomb || wpnId==wSBomb || wpnId==wSword) && stunclk>0)
3916 return 1;
3917
3918
3919 if(!switch_hooked)
3920 stunclk=160;
3921 break;
3922 }
3923 2 }
3924 71999 else hp-=power;
3925
3926 hitclock:
3927 77198 hclk=33;
3928
3929 // Use w->dir instead of wpnDir to make sure boomerangs don't push enemies the wrong way
3930
2/2
✓ Branch 0 taken 34515 times.
✓ Branch 1 taken 42683 times.
77198 if((dir&2)==(w->dir&2))
3931 {
3932 42683 sclk=(w->dir<<8)+16;
3933 42683 }
3934 77198 }
3935
3936
5/6
✓ Branch 0 taken 73785 times.
✓ Branch 1 taken 19558 times.
✓ Branch 2 taken 21969 times.
✓ Branch 3 taken 71374 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 21969 times.
93343 if(((wpnId==wBrang) || (get_qr(qr_NOFLASHDEATH))) && (hp<=0 && !immortal))
3937 {
3938 21969 fading=fade_blue_poof;
3939 21969 }
3940
3941
6/6
✓ Branch 0 taken 88410 times.
✓ Branch 1 taken 4933 times.
✓ Branch 2 taken 46745 times.
✓ Branch 3 taken 41665 times.
✓ Branch 4 taken 2155 times.
✓ Branch 5 taken 44590 times.
93343 if ( FFCore.getQuestHeaderInfo(vZelda) > 0x250 || ( FFCore.getQuestHeaderInfo(vZelda) == 0x250 && FFCore.getQuestHeaderInfo(vBuild) > 31 )) //2.53 Gamma 2 and later
3942 {
3943
2/2
✓ Branch 0 taken 7081 times.
✓ Branch 1 taken 7 times.
7088 if( hitsfx > 0 ) //user-set hit sound.
3944 {
3945
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7081 times.
7081 if (!dying) //don't play the hit sound on death! -Z
3946 7081 sfx(hitsfx, pan(int32_t(x)));
3947 7081 }
3948 7 else sfx(WAV_EHIT, pan(int32_t(x))); //Don't play the hardcoded sound if the user sets a custom one.
3949 7088 }
3950 else //2.50.2 or earlier
3951 {
3952 86255 sfx(WAV_EHIT, pan(int32_t(x)));
3953 86255 sfx(hitsfx, pan(int32_t(x)));
3954 }
3955
2/2
✓ Branch 0 taken 93314 times.
✓ Branch 1 taken 29 times.
93343 if(family==eeGUY)
3956 29 sfx(WAV_EDEAD, pan(int32_t(x)));
3957
3958 // Penetrating weapons
3959
4/4
✓ Branch 0 taken 91482 times.
✓ Branch 1 taken 1861 times.
✓ Branch 2 taken 84583 times.
✓ Branch 3 taken 8760 times.
93343 if((wpnId==wArrow || wpnId==wBeam) && !cannotpenetrate())
3960 {
3961 8760 int32_t item=enemyHitWeapon;
3962
3963
2/2
✓ Branch 0 taken 1599 times.
✓ Branch 1 taken 7161 times.
8760 if(wpnId==wArrow)
3964 {
3965 //If we use an arrow type for the item's Weapon type, the flags differ, so we need to rely on the flags from an arrow class.
3966
5/6
✓ Branch 0 taken 1484 times.
✓ Branch 1 taken 115 times.
✓ Branch 2 taken 379 times.
✓ Branch 3 taken 1105 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 379 times.
1599 if(item>=0 && (itemsbuf[item].flags&item_flag1) && (itemsbuf[parent_item].family == itype_arrow))
3967 379 return 0;
3968
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1220 times.
1220 else if(get_qr(qr_ARROWS_ALWAYS_PENETRATE)) return 0;
3969 //if(item<0)
3970 else
3971 1220 item=current_item_id(itype_arrow);
3972 1220 }
3973
3974 else
3975 {
3976
3977 //If we use an swordbeam type for the item's Weapon type, the flags differ, so we need to rely on the flags from an arrow class.
3978
3/6
✓ Branch 0 taken 7143 times.
✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7143 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
7161 if(item>=0 && (itemsbuf[item].flags&item_flag3) && (itemsbuf[parent_item].family == itype_sword))
3979 return 0;
3980
3981
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7161 times.
7161 else if(get_qr(qr_SWORDBEAMS_ALWAYS_PENETRATE)) return 0;
3982 else
3983 //if(item<0)
3984 7161 item=current_item_id(itype_sword);
3985 }
3986 8381 }
3987
3988 92964 return ret;
3989 268817 }
3990
3991 61491740 bool enemy::dont_draw()
3992 {
3993
6/6
✓ Branch 0 taken 61028954 times.
✓ Branch 1 taken 462786 times.
✓ Branch 2 taken 60958047 times.
✓ Branch 3 taken 70907 times.
✓ Branch 4 taken 171995 times.
✓ Branch 5 taken 60856959 times.
61491740 if(fading==fade_invisible || (((flags&guy_blinking)||(fading==fade_flicker)) && (clk&1)))
3994 634781 return true;
3995
3996
2/2
✓ Branch 0 taken 1371477 times.
✓ Branch 1 taken 59485482 times.
60856959 if(flags&guy_invisible)
3997 1371477 return true;
3998
3999
3/4
✓ Branch 0 taken 432 times.
✓ Branch 1 taken 59485050 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 432 times.
59485482 if(flags&guy_lens_only && !lensclk)
4000 return true;
4001
4002 59485482 return false;
4003 61491740 }
4004
4005 #define DRAW_NORMAL 2
4006 #define DRAW_CLOAKED 1
4007 #define DRAW_INVIS 0
4008 // base drawing function to be used by all derived classes instead of
4009 // sprite::draw()
4010 44700316 void enemy::draw(BITMAP *dest)
4011 {
4012 44700316 didScriptThisFrame = false; //Since there's no better place to put it
4013
6/6
✓ Branch 0 taken 43936911 times.
✓ Branch 1 taken 763405 times.
✓ Branch 2 taken 43854261 times.
✓ Branch 3 taken 82650 times.
✓ Branch 4 taken 314518 times.
✓ Branch 5 taken 43622393 times.
44700316 if(fading==fade_invisible || (((flags&guy_blinking)||(fading==fade_flicker)) && (clk&1)))
4014 1077923 return;
4015
2/2
✓ Branch 0 taken 2767665 times.
✓ Branch 1 taken 40854728 times.
43622393 if(flags&guy_invisible)
4016 2767665 return;
4017
4018 //We did the normal don't_draw stuff here so we can make exceptions; specifically the lens check (which should make enemies
4019 // be cloaked if they have "invisible displays as cloaked" checked.
4020
4021 40854728 byte canSee = DRAW_NORMAL;
4022 //Enemy specific stuff
4023
2/2
✓ Branch 0 taken 40853564 times.
✓ Branch 1 taken 1164 times.
40854728 if ( editorflags & ENEMY_FLAG1 )
4024 {
4025 1164 canSee = DRAW_INVIS;
4026
1/2
✓ Branch 0 taken 1164 times.
✗ Branch 1 not taken.
1164 if (editorflags & ENEMY_FLAG4) canSee = DRAW_CLOAKED;
4027
2/4
✓ Branch 0 taken 1164 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1164 times.
✗ Branch 3 not taken.
1164 if (dmisc13 >= 0 && (editorflags & ENEMY_FLAG2))
4028 {
4029 if (game->item[dmisc13])
4030 {
4031 canSee = DRAW_NORMAL;
4032 }
4033 //else if ( lensclk && getlensid.flags SHOWINVIS )
4034 //{
4035 //
4036 //}
4037 //else
4038 //{
4039 // if ( (editorflags & ENEMY_FLAG4) ) canSee = DRAW_CLOAKED;
4040 // //otherwisem invisible
4041 //}
4042 }
4043 1164 }
4044 //Room specific
4045
2/2
✓ Branch 0 taken 38683529 times.
✓ Branch 1 taken 2171199 times.
40854728 if (tmpscr->flags3&fINVISROOM)
4046 {
4047
4/6
✓ Branch 0 taken 2171199 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 226004 times.
✓ Branch 3 taken 1945195 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 226004 times.
2397203 if (canSee == DRAW_NORMAL && !(current_item(itype_amulet)) &&
4048
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 226004 times.
226004 !((itemsbuf[Hero.getLastLensID()].flags & item_flag5) && lensclk) && family!=eeGANON) canSee = DRAW_CLOAKED;
4049 2171199 }
4050 //Lens check
4051
2/2
✓ Branch 0 taken 27345 times.
✓ Branch 1 taken 40827383 times.
40854728 if (lensclk)
4052 {
4053
2/2
✓ Branch 0 taken 26913 times.
✓ Branch 1 taken 432 times.
27345 if(flags&guy_lens_only)
4054 {
4055
1/2
✓ Branch 0 taken 432 times.
✗ Branch 1 not taken.
432 if (canSee == DRAW_INVIS) canSee = DRAW_NORMAL;
4056 432 }
4057 27345 }
4058 else
4059 {
4060
2/2
✓ Branch 0 taken 40753967 times.
✓ Branch 1 taken 73416 times.
40827383 if(flags&guy_lens_only)
4061 73416 canSee = DRAW_INVIS;
4062 }
4063
3/4
✓ Branch 0 taken 74580 times.
✓ Branch 1 taken 40780148 times.
✓ Branch 2 taken 74580 times.
✗ Branch 3 not taken.
40854728 if (canSee == DRAW_INVIS && (editorflags & ENEMY_FLAG4)) canSee = DRAW_CLOAKED;
4064
3/4
✓ Branch 0 taken 40554144 times.
✓ Branch 1 taken 300584 times.
✓ Branch 2 taken 40554144 times.
✗ Branch 3 not taken.
40854728 if (canSee == DRAW_NORMAL && (editorflags & ENEMY_FLAG16)) canSee = DRAW_CLOAKED;
4065
4066
2/2
✓ Branch 0 taken 40780148 times.
✓ Branch 1 taken 74580 times.
40854728 if (canSee == DRAW_INVIS)
4067 74580 return;
4068
4069
4/4
✓ Branch 0 taken 40777842 times.
✓ Branch 1 taken 2306 times.
✓ Branch 2 taken 7 times.
✓ Branch 3 taken 40777835 times.
40780148 if(fallclk||drownclk)
4070 {
4071
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2313 times.
2313 if (canSee == DRAW_CLOAKED)
4072 {
4073 sprite::drawcloaked(dest);
4074 }
4075
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2313 times.
2313 else if (canSee == DRAW_NORMAL)
4076 {
4077 2313 sprite::draw(dest);
4078 2313 }
4079 2313 return;
4080 }
4081 40777835 int32_t cshold=cs;
4082
4083
2/2
✓ Branch 0 taken 901525 times.
✓ Branch 1 taken 39876310 times.
40777835 if(dying)
4084 {
4085
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 901525 times.
901525 if(clk2>=19)
4086 {
4087 if(!(clk2&2))
4088 {
4089 //if the enemy isn't totally invisible, or if it is, but Hero has the item needed to reveal it, draw it.
4090 if (canSee == DRAW_CLOAKED)
4091 {
4092 sprite::drawcloaked(dest);
4093 }
4094 else if (canSee == DRAW_NORMAL)
4095 {
4096 sprite::draw(dest);
4097 }
4098 }
4099 return;
4100 }
4101
4102 901525 flip = 0;
4103 901525 tile = wpnsbuf[spr_death].tile;
4104
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 901525 times.
901525 if ( do_animation )
4105 {
4106 901525 int32_t offs = 0;
4107
2/2
✓ Branch 0 taken 850658 times.
✓ Branch 1 taken 50867 times.
901525 if(!get_qr(qr_HARDCODED_ENEMY_ANIMS))
4108 {
4109
2/2
✓ Branch 0 taken 49251 times.
✓ Branch 1 taken 1616 times.
50867 if(clk2 > 2)
4110 {
4111 1616 spr_death_anim_clk=0;
4112 1616 clk2=1;
4113
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 1602 times.
1616 if(hp > -1000)
4114 1602 death_sfx();
4115 1616 }
4116
4/4
✓ Branch 0 taken 38168 times.
✓ Branch 1 taken 12699 times.
✓ Branch 2 taken 402 times.
✓ Branch 3 taken 37766 times.
50867 if(clk2==1 && spr_death_anim_clk>-1)
4117 {
4118 37766 ++clk2;
4119
2/2
✓ Branch 0 taken 2382 times.
✓ Branch 1 taken 35384 times.
37766 spr_death_anim_frm=(spr_death_anim_clk/zc_max(wpnsbuf[spr_death].speed,1));
4120
2/2
✓ Branch 0 taken 21 times.
✓ Branch 1 taken 37745 times.
37766 spr_death_anim_frm *= zc_max(1,txsz);
4121 37766 int32_t rows = TILEROW(tile+spr_death_anim_frm)-TILEROW(tile);
4122
2/2
✓ Branch 0 taken 76 times.
✓ Branch 1 taken 37690 times.
37766 spr_death_anim_frm += TILES_PER_ROW*(zc_min(0,tysz-1)*rows);
4123
6/6
✓ Branch 0 taken 2382 times.
✓ Branch 1 taken 35384 times.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 37764 times.
✓ Branch 4 taken 36168 times.
✓ Branch 5 taken 1598 times.
37766 if(++spr_death_anim_clk >= (zc_max(wpnsbuf[spr_death].speed,1) * zc_max(wpnsbuf[spr_death].frames,1)))
4124 {
4125 1598 spr_death_anim_clk=-1;
4126 1598 clk2=1;
4127 1598 }
4128 37766 }
4129 50867 tile += spr_death_anim_frm;
4130 50867 }
4131
2/2
✓ Branch 0 taken 313513 times.
✓ Branch 1 taken 537145 times.
850658 else if(BSZ)
4132 {
4133
2/2
✓ Branch 0 taken 246522 times.
✓ Branch 1 taken 66991 times.
313513 offs = zc_min((15-clk2)/3,4);
4134 313513 }
4135
4/4
✓ Branch 0 taken 358175 times.
✓ Branch 1 taken 178970 times.
✓ Branch 2 taken 178959 times.
✓ Branch 3 taken 179216 times.
537145 else if(clk2>6 && clk2<=12)
4136 {
4137 179216 offs = 1;
4138 179216 }
4139
4140
2/2
✓ Branch 0 taken 454946 times.
✓ Branch 1 taken 446579 times.
901525 if(offs)
4141 {
4142
2/2
✓ Branch 0 taken 450 times.
✓ Branch 1 taken 446129 times.
446579 offs *= zc_max(1,txsz);
4143 446579 int32_t rows = TILEROW(tile+offs)-TILEROW(tile);
4144
2/2
✓ Branch 0 taken 438 times.
✓ Branch 1 taken 446141 times.
446579 offs += TILES_PER_ROW*(zc_min(0,tysz-1)*rows);
4145 446579 }
4146 901525 tile += offs;
4147 901525 }
4148
4149
6/6
✓ Branch 0 taken 850658 times.
✓ Branch 1 taken 50867 times.
✓ Branch 2 taken 537145 times.
✓ Branch 3 taken 313513 times.
✓ Branch 4 taken 189182 times.
✓ Branch 5 taken 347963 times.
901525 if(!get_qr(qr_HARDCODED_ENEMY_ANIMS) || BSZ || fading==fade_blue_poof)
4150 553562 cs = wpnsbuf[spr_death].csets&15;
4151 else
4152 347963 cs = (((clk2+5)>>1)&3)+6;
4153 901525 }
4154
3/4
✓ Branch 0 taken 1189380 times.
✓ Branch 1 taken 38686930 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1189380 times.
39876310 else if(hclk>0 && getCanFlicker())
4155 {
4156 1189380 cs = getFlashingCSet();
4157 1189380 }
4158 //draw every other frame for flickering enemies
4159
2/2
✓ Branch 0 taken 248031 times.
✓ Branch 1 taken 40529804 times.
40777835 if (is_hitflickerframe(false))
4160 {
4161
5/6
✓ Branch 0 taken 90246 times.
✓ Branch 1 taken 157785 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 90245 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 157786 times.
248031 int32_t temp_flicker_color = (hp > 0 || immortal) ? (flickercolor < 0 ? game->get_spriteflickercolor() : flickercolor) : 0;
4162
2/4
✓ Branch 0 taken 248031 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 248031 times.
248031 if (game->get_spriteflickercolor() || temp_flicker_color)
4163 {
4164 sprite_flicker_transp_passes = (flickertransp < 0 ? game->get_spriteflickertransp() : flickertransp);
4165 sprite_flicker_color = temp_flicker_color;
4166 sprite::draw(dest);
4167 }
4168 248031 }
4169 else
4170 {
4171
2/2
✓ Branch 0 taken 225162 times.
✓ Branch 1 taken 40304642 times.
40529804 if (canSee == DRAW_CLOAKED)
4172 {
4173 225162 sprite::drawcloaked(dest);
4174 225162 }
4175
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 40304642 times.
40304642 else if (canSee == DRAW_NORMAL)
4176 {
4177
1/2
✓ Branch 0 taken 40304642 times.
✗ Branch 1 not taken.
40304642 if ( frozenclock < 0 )
4178 {
4179 if ( frozentile > 0 ) tile = frozentile;
4180 loadpalset(csBOSS,frozencset);
4181 }
4182 40304642 sprite::draw(dest);
4183 40304642 }
4184 }
4185 40777835 cs=cshold;
4186 44700316 }
4187
4188 //old zc bosses
4189 40751050 void enemy::drawzcboss(BITMAP *dest)
4190 {
4191 40751050 didScriptThisFrame = false; //Since there's no better place to put it
4192
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 40751050 times.
40751050 if(dont_draw())
4193 return;
4194
4195 40751050 int32_t cshold=cs;
4196
4197
2/2
✓ Branch 0 taken 781584 times.
✓ Branch 1 taken 39969466 times.
40751050 if(dying)
4198 {
4199
2/2
✓ Branch 0 taken 3960 times.
✓ Branch 1 taken 777624 times.
781584 if(clk2>=19)
4200 {
4201
2/2
✓ Branch 0 taken 1980 times.
✓ Branch 1 taken 1980 times.
3960 if(!(clk2&2))
4202 1980 sprite::drawzcboss(dest);
4203
4204 3960 return;
4205 }
4206
4207 777624 flip = 0;
4208 777624 tile = wpnsbuf[spr_death].tile;
4209
4210
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 777624 times.
777624 if ( do_animation )
4211 {
4212
2/2
✓ Branch 0 taken 773108 times.
✓ Branch 1 taken 4516 times.
777624 if(!get_qr(qr_HARDCODED_ENEMY_ANIMS))
4213 {
4214
2/2
✓ Branch 0 taken 4510 times.
✓ Branch 1 taken 6 times.
4516 if(clk2 > 2)
4215 {
4216 6 spr_death_anim_clk=0;
4217 6 clk2=1;
4218
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
6 if(hp > -1000)
4219 6 death_sfx();
4220 6 }
4221
4/4
✓ Branch 0 taken 260 times.
✓ Branch 1 taken 4256 times.
✓ Branch 2 taken 184 times.
✓ Branch 3 taken 76 times.
4516 if(clk2==1 && spr_death_anim_clk>-1)
4222 {
4223 76 ++clk2;
4224
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 76 times.
76 spr_death_anim_frm=(spr_death_anim_clk/zc_max(wpnsbuf[spr_death].speed,1));
4225
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 76 times.
76 spr_death_anim_frm *= zc_max(1,txsz);
4226 76 int32_t rows = TILEROW(tile+spr_death_anim_frm)-TILEROW(tile);
4227
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 76 times.
76 spr_death_anim_frm += TILES_PER_ROW*(zc_min(0,tysz-1)*rows);
4228
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 76 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 76 times.
✓ Branch 4 taken 74 times.
✓ Branch 5 taken 2 times.
76 if(++spr_death_anim_clk >= (zc_max(wpnsbuf[spr_death].speed,1) * zc_max(wpnsbuf[spr_death].frames,1)))
4229 {
4230 2 spr_death_anim_clk=-1;
4231 2 clk2=1;
4232 2 }
4233 76 }
4234 4516 tile += spr_death_anim_frm;
4235 4516 }
4236
2/2
✓ Branch 0 taken 276492 times.
✓ Branch 1 taken 496616 times.
773108 else if(BSZ)
4237
2/2
✓ Branch 0 taken 217484 times.
✓ Branch 1 taken 59008 times.
276492 tile += zc_min((15-clk2)/3,4);
4238
4/4
✓ Branch 0 taken 331041 times.
✓ Branch 1 taken 165575 times.
✓ Branch 2 taken 165418 times.
✓ Branch 3 taken 165623 times.
496616 else if(clk2>6 && clk2<=12)
4239 165623 ++tile;
4240 777624 }
4241
4242
6/6
✓ Branch 0 taken 773108 times.
✓ Branch 1 taken 4516 times.
✓ Branch 2 taken 496616 times.
✓ Branch 3 taken 276492 times.
✓ Branch 4 taken 183872 times.
✓ Branch 5 taken 312744 times.
777624 if(!get_qr(qr_HARDCODED_ENEMY_ANIMS) || BSZ || fading==fade_blue_poof)
4243 464880 cs = wpnsbuf[spr_death].csets&15;
4244 else
4245 312744 cs = (((clk2+5)>>1)&3)+6;
4246 777624 }
4247
2/2
✓ Branch 0 taken 38769460 times.
✓ Branch 1 taken 1200006 times.
39969466 else if(hclk>0)
4248 {
4249 1200006 cs = getFlashingCSet();
4250 1200006 }
4251
4252
3/4
✓ Branch 0 taken 2045619 times.
✓ Branch 1 taken 38701471 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7543 times.
40754633 if((tmpscr->flags3&fINVISROOM) &&
4253
2/2
✓ Branch 0 taken 7543 times.
✓ Branch 1 taken 2038076 times.
2045619 !(current_item(itype_amulet)) &&
4254
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7543 times.
7543 !(get_qr(qr_LENSSEESENEMIES) &&
4255 7543 lensclk) && family!=eeGANON)
4256 {
4257 7543 sprite::drawcloaked(dest);
4258 7543 }
4259 else
4260 {
4261
2/2
✓ Branch 0 taken 23473 times.
✓ Branch 1 taken 40716074 times.
40739547 if (is_hitflickerframe(true))
4262 {
4263
4/6
✓ Branch 0 taken 885 times.
✓ Branch 1 taken 22588 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 885 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 22588 times.
23473 int32_t temp_flicker_color = (hp > 0 || immortal) ? (flickercolor < 0 ? game->get_spriteflickercolor() : flickercolor) : 0;
4264
1/2
✓ Branch 0 taken 23473 times.
✗ Branch 1 not taken.
23473 if (game->get_spriteflickercolor())
4265 {
4266 sprite_flicker_transp_passes = (flickertransp < 0 ? game->get_spriteflickertransp() : flickertransp);
4267 sprite_flicker_color = temp_flicker_color;
4268 sprite::drawzcboss(dest);
4269 }
4270 23473 }
4271 else
4272 40716074 sprite::drawzcboss(dest);
4273 }
4274
4275 40747090 cs=cshold;
4276 40751050 }
4277
4278
4279 // similar to the overblock function--can do up to a 32x32 sprite
4280 //will this play nicely with scripttile, solely using the modifications in sprite::draw()?
4281 323235 void enemy::drawblock(BITMAP *dest,int32_t mask)
4282 {
4283 323235 int32_t thold=tile;
4284 323235 int32_t t1=tile;
4285 323235 int32_t t2=tile+20;
4286 323235 int32_t t3=tile+1;
4287 323235 int32_t t4=tile+21;
4288
4289
1/5
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 323235 times.
323235 switch(mask)
4290 {
4291 case 1:
4292 enemy::drawzcboss(dest);
4293 break;
4294
4295 case 3:
4296 if(flip&2)
4297 zc_swap(t1,t2);
4298
4299 tile=t1;
4300 enemy::drawzcboss(dest);
4301 tile=t2;
4302 yofs+=16;
4303 enemy::drawzcboss(dest);
4304 yofs-=16;
4305 break;
4306
4307 case 5:
4308 t2=tile+1;
4309
4310 if(flip&1)
4311 zc_swap(t1,t2);
4312
4313 tile=t1;
4314 enemy::drawzcboss(dest);
4315 tile=t2;
4316 xofs+=16;
4317 enemy::drawzcboss(dest);
4318 xofs-=16;
4319 break;
4320
4321 case 15:
4322
2/2
✓ Branch 0 taken 316479 times.
✓ Branch 1 taken 6756 times.
323235 if(flip&1)
4323 {
4324 6756 zc_swap(t1,t3);
4325 6756 zc_swap(t2,t4);
4326 6756 }
4327
4328
1/2
✓ Branch 0 taken 323235 times.
✗ Branch 1 not taken.
323235 if(flip&2)
4329 {
4330 zc_swap(t1,t2);
4331 zc_swap(t3,t4);
4332 }
4333
4334 323235 tile=t1;
4335 323235 enemy::drawzcboss(dest);
4336 323235 tile=t2;
4337 323235 yofs+=16;
4338 323235 enemy::drawzcboss(dest);
4339 323235 yofs-=16;
4340 323235 tile=t3;
4341 323235 xofs+=16;
4342 323235 enemy::drawzcboss(dest);
4343 323235 tile=t4;
4344 323235 yofs+=16;
4345 323235 enemy::drawzcboss(dest);
4346 323235 xofs-=16;
4347 323235 yofs-=16;
4348 323235 break;
4349 }
4350
4351 323235 tile=thold;
4352 323235 }
4353
4354 20176865 void enemy::drawshadow(BITMAP *dest, bool translucent)
4355 {
4356
4/4
✓ Branch 0 taken 18170607 times.
✓ Branch 1 taken 2006258 times.
✓ Branch 2 taken 406089 times.
✓ Branch 3 taken 17764518 times.
20176865 if(dont_draw() || isSideViewGravity())
4357 {
4358 2412347 return;
4359 }
4360
4361
2/2
✓ Branch 0 taken 326866 times.
✓ Branch 1 taken 17437652 times.
17764518 if(dying)
4362 {
4363 326866 return;
4364 }
4365
4366
4/4
✓ Branch 0 taken 1718249 times.
✓ Branch 1 taken 15719403 times.
✓ Branch 2 taken 347010 times.
✓ Branch 3 taken 17090642 times.
17437652 if(((tmpscr->flags3&fINVISROOM)&& !(current_item(itype_amulet)))||
4367 17437652 (darkroom))
4368 {
4369 347010 return;
4370 }
4371 else
4372 {
4373
4/4
✓ Branch 0 taken 16516736 times.
✓ Branch 1 taken 573906 times.
✓ Branch 2 taken 16469365 times.
✓ Branch 3 taken 47371 times.
17090642 if(enemycanfall(id, false) && shadowtile == 0)
4374 47371 shadowtile = wpnsbuf[spr_shadow].tile;
4375
4376
5/6
✓ Branch 0 taken 16152278 times.
✓ Branch 1 taken 938364 times.
✓ Branch 2 taken 16152278 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 15578372 times.
✓ Branch 5 taken 573906 times.
17090642 if(z>0 || fakez>0 || !enemycanfall(id, false))
4377 {
4378
2/2
✓ Branch 0 taken 275 times.
✓ Branch 1 taken 1511995 times.
1512270 if(!shadow_overpit(this))
4379 1511995 sprite::drawshadow(dest,translucent);
4380 1512270 }
4381 }
4382 20176865 }
4383
4384 129181 void enemy::masked_draw(BITMAP *dest,int32_t mx,int32_t my,int32_t mw,int32_t mh)
4385 {
4386 129181 BITMAP *sub=create_sub_bitmap(dest,mx,my,mw,mh);
4387
4388
1/2
✓ Branch 0 taken 129181 times.
✗ Branch 1 not taken.
129181 if(sub!=NULL)
4389 {
4390 129181 xofs-=mx;
4391 129181 yofs-=my;
4392 129181 enemy::draw(sub);
4393 129181 xofs+=mx;
4394 129181 yofs+=my;
4395 129181 destroy_bitmap(sub);
4396 129181 }
4397 else
4398 enemy::draw(dest);
4399 129181 }
4400
4401 9 void enemy::init_size_flags()
4402 {
4403
3/6
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 9 times.
9 if (((SIZEflags & OVERRIDE_TILE_WIDTH) != 0) && d->txsz > 0) { txsz = d->txsz; if (txsz > 1) extend = 3; }
4404
3/6
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 9 times.
9 if (((SIZEflags & OVERRIDE_TILE_HEIGHT) != 0) && d->tysz > 0) { tysz = d->tysz; if (tysz > 1) extend = 3; }
4405
3/4
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7 times.
9 if (((SIZEflags & OVERRIDE_HIT_WIDTH) != 0) && d->hxsz >= 0) hit_width = d->hxsz;
4406
3/4
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7 times.
9 if (((SIZEflags & OVERRIDE_HIT_HEIGHT) != 0) && d->hysz >= 0) hit_height = d->hysz;
4407
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
9 if (((SIZEflags & OVERRIDE_HIT_Z_HEIGHT) != 0) && d->hzsz >= 0) hzsz = d->hzsz;
4408
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if ((SIZEflags & OVERRIDE_HIT_X_OFFSET) != 0) hxofs = d->hxofs;
4409
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if ((SIZEflags & OVERRIDE_HIT_Y_OFFSET) != 0) hyofs = d->hyofs;
4410
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if ((SIZEflags & OVERRIDE_DRAW_X_OFFSET) != 0) xofs = (int32_t)d->xofs;
4411
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if ((SIZEflags & OVERRIDE_DRAW_Y_OFFSET) != 0)
4412 {
4413 yofs = (int32_t)d->yofs;
4414 yofs += (get_qr(qr_OLD_DRAWOFFSET) ? playing_field_offset : original_playing_field_offset);
4415 }
4416
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if ((SIZEflags & OVERRIDE_DRAW_Z_OFFSET) != 0) zofs = (int32_t)d->zofs;
4417 9 }
4418
4419 // override hit detection to check for invicibility, stunned, etc
4420 112146621 bool enemy::hit()
4421 {
4422
4/4
✓ Branch 0 taken 110823541 times.
✓ Branch 1 taken 1323080 times.
✓ Branch 2 taken 109028765 times.
✓ Branch 3 taken 1794776 times.
112146621 if(dying || hclk>0) return false;
4423 109028765 return sprite::hit();
4424 112146621 }
4425 730351 bool enemy::hit(sprite *s)
4426 {
4427
3/4
✓ Branch 0 taken 730351 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 713374 times.
✓ Branch 3 taken 16977 times.
730351 if(!hit() || !s->hit()) return false;
4428 713374 return sprite::hit(s);
4429 730351 }
4430
4431 44499041 bool enemy::hit(int32_t tx,int32_t ty,int32_t tz,int32_t txsz2,int32_t tysz2,int32_t tzsz2)
4432 {
4433
2/2
✓ Branch 0 taken 3918687 times.
✓ Branch 1 taken 40580354 times.
44499041 if(!hit()) return false;
4434 40580354 return sprite::hit(tx,ty,tz,txsz2,tysz2,tzsz2);
4435 44499041 }
4436 78011 bool enemy::hit(int32_t tx,int32_t ty,int32_t txsz2,int32_t tysz2)
4437 {
4438
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 78011 times.
78011 if(!hit()) return false;
4439 78011 return sprite::hit(tx,ty,txsz2,tysz2);
4440 78011 }
4441
4442 11132690 bool enemy::hit(weapon *w)
4443 {
4444
2/2
✓ Branch 0 taken 1172238 times.
✓ Branch 1 taken 9960452 times.
11132690 if(!hit()) return false;
4445
4446
2/2
✓ Branch 0 taken 6645889 times.
✓ Branch 1 taken 3314563 times.
9960452 if (replay_version_check(0, 14))
4447 {
4448
4/6
✓ Branch 0 taken 6421582 times.
✓ Branch 1 taken 224307 times.
✓ Branch 2 taken 6421582 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 6421582 times.
✗ Branch 5 not taken.
6645889 if(!w->scriptcoldet || w->fallclk || w->drownclk)
4449 224307 return false;
4450 6421582 return sprite::hit(w);
4451 }
4452 3314563 return w->hit(this);
4453 11132690 }
4454
4455 9454558 bool enemy::can_pitfall(bool checkspawning)
4456 {
4457
4/4
✓ Branch 0 taken 9434867 times.
✓ Branch 1 taken 19691 times.
✓ Branch 2 taken 9424212 times.
✓ Branch 3 taken 30346 times.
9454558 if((fading||isspawning)&&checkspawning) return false; //Don't fall during spawn.
4458
2/2
✓ Branch 0 taken 9406553 times.
✓ Branch 1 taken 17659 times.
9424212 switch(guysbuf[id&0xFFF].family)
4459 {
4460 case eeAQUA:
4461 case eeDIG:
4462 case eeDONGO:
4463 case eeFAIRY:
4464 case eeGANON:
4465 case eeGHOMA:
4466 case eeGLEEOK:
4467 case eeGUY:
4468 case eeLANM:
4469 case eeMANHAN:
4470 case eeMOLD:
4471 case eeNONE:
4472 case eePATRA:
4473 case eeZORA:
4474 17659 return false; //Disallowed types
4475 default:
4476 9406553 return true;
4477 }
4478 9454558 }
4479 //Handle death
4480 37821672 void enemy::try_death(bool force_kill)
4481 {
4482
8/8
✓ Branch 0 taken 37766717 times.
✓ Branch 1 taken 54955 times.
✓ Branch 2 taken 37766706 times.
✓ Branch 3 taken 11 times.
✓ Branch 4 taken 43493 times.
✓ Branch 5 taken 37723213 times.
✓ Branch 6 taken 1 times.
✓ Branch 7 taken 43492 times.
37821672 if(!dying && (force_kill || (hp<=0 && !immortal)))
4483 {
4484 43503 std::vector<int32_t> &ev = FFCore.eventData;
4485 43503 ev.clear();
4486 43503 ev.push_back(10000);
4487 43503 ev.push_back(getUID());
4488
4489 43503 throwGenScriptEvent(GENSCR_EVENT_ENEMY_DEATH);
4490 43503 bool isSaved = !ev[0];
4491 43503 ev.clear();
4492
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 43503 times.
43503 if(isSaved) return;
4493
4494
4/4
✓ Branch 0 taken 48 times.
✓ Branch 1 taken 43455 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 42 times.
43503 if(itemguy && (hasitem&2)!=0)
4495 {
4496
2/2
✓ Branch 0 taken 47 times.
✓ Branch 1 taken 42 times.
89 for(int32_t i=0; i<items.Count(); i++)
4497 {
4498
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 42 times.
47 if(((item*)items.spr(i))->pickup&ipENEMY)
4499 {
4500
2/2
✓ Branch 0 taken 41 times.
✓ Branch 1 taken 1 times.
42 if (!get_qr(qr_BROKEN_ITEM_CARRYING))
4501 {
4502
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if (get_qr(qr_ENEMY_DROPS_USE_HITOFFSETS))
4503 {
4504 items.spr(i)->x = x+hxofs+(hit_width/2)-8;
4505 items.spr(i)->y = y+hyofs+(hit_height/2)-10-fakez;
4506 }
4507 else
4508 {
4509
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if(extend >= 3)
4510 {
4511 items.spr(i)->x = x+(txsz-1)*8;
4512 items.spr(i)->y = y-2+(tysz-1)*8;
4513 }
4514 else
4515 {
4516 1 items.spr(i)->x = x;
4517 1 items.spr(i)->y = y - 2;
4518 }
4519 }
4520 1 items.spr(i)->z = z;
4521 1 items.spr(i)->fakez = fakez;
4522 1 }
4523 else
4524 {
4525 41 items.spr(i)->x = x;
4526 41 items.spr(i)->y = y - 2;
4527 }
4528 42 }
4529 47 }
4530 42 }
4531
4532 43503 dying=true;
4533
4534
2/2
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 43471 times.
43503 if(fading==fade_flash_die)
4535 32 clk2=19+18*4;
4536 else
4537 {
4538 43471 clk2 = BSZ ? 15 : 19;
4539
4540
2/2
✓ Branch 0 taken 21051 times.
✓ Branch 1 taken 22420 times.
43471 if(fading!=fade_blue_poof)
4541 22420 fading=0;
4542 }
4543
4544
2/2
✓ Branch 0 taken 43455 times.
✓ Branch 1 taken 48 times.
43503 if(itemguy)
4545 {
4546 48 hasitem&=~2;
4547 48 item_set=0;
4548 48 }
4549
4550
6/6
✓ Branch 0 taken 42449 times.
✓ Branch 1 taken 1054 times.
✓ Branch 2 taken 33764 times.
✓ Branch 3 taken 8685 times.
✓ Branch 4 taken 1413 times.
✓ Branch 5 taken 32351 times.
43503 if(currscr<128 && count_enemy && !script_spawned)
4551 32351 game->guys[(currmap<<7)+currscr]-=1;
4552 43503 }
4553 37821672 }
4554
4555 // --==**==--
4556
4557 // Movement routines that can be used by derived classes as needed
4558
4559 // --==**==--
4560
4561 555795 void enemy::fix_coords(bool bound)
4562 {
4563
1/2
✓ Branch 0 taken 555795 times.
✗ Branch 1 not taken.
555795 if ((get_qr(qr_OUTOFBOUNDSENEMIES) ? 1 : 0) ^ ((editorflags&ENEMY_FLAG11)?1:0)) return;
4564
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 555795 times.
555795 if(moveflags & move_ignore_screenedge) bound = false;
4565
4566
4567
2/2
✓ Branch 0 taken 81680 times.
✓ Branch 1 taken 474115 times.
555795 if(bound)
4568 {
4569
1/2
✓ Branch 0 taken 474115 times.
✗ Branch 1 not taken.
474115 if ( ((unsigned)(id&0xFFF)) < MAXGUYS )
4570 {
4571
3/4
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 474113 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
474115 x=vbound(x, 0_zf, (( guysbuf[id].SIZEflags&OVERRIDE_TILE_WIDTH && !isflier(id) ) ? (256_zf -((txsz-1)*16)) : 240_zf));
4572
3/4
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 474113 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
474115 y=vbound(y, 0_zf,(( guysbuf[id].SIZEflags&OVERRIDE_TILE_HEIGHT && !isflier(id) ) ? (176_zf -((txsz-1)*16)) : 160_zf));
4573 474115 }
4574 else
4575 {
4576 x=vbound(x, 0_zf,240_zf);
4577 y=vbound(y, 0_zf,160_zf);
4578 }
4579 474115 }
4580
4581
6/10
✓ Branch 0 taken 554781 times.
✓ Branch 1 taken 1014 times.
✓ Branch 2 taken 555795 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 555795 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 555795 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 555795 times.
555795 if(!OUTOFBOUNDS)
4582 {
4583 /*x=((int32_t(x)&0xF0)+((int32_t(x)&8)?16:0));
4584
4585 if(isSideViewGravity())
4586 y=((int32_t(y)&0xF8)+((int32_t(y)&4)?8:0));
4587 else
4588 y=((int32_t(y)&0xF0)+((int32_t(y)&8)?16:0));
4589 */
4590 555795 do_fix(x, 16, true);
4591
2/2
✓ Branch 0 taken 1014 times.
✓ Branch 1 taken 554781 times.
555795 if(isSideViewGravity())
4592 1014 do_fix(y,8,true);
4593 554781 else do_fix(y,16,true);
4594 555795 }
4595 555795 }
4596 9156 bool enemy::cannotpenetrate()
4597 {
4598
4/4
✓ Branch 0 taken 8975 times.
✓ Branch 1 taken 181 times.
✓ Branch 2 taken 38 times.
✓ Branch 3 taken 8937 times.
9156 return (family == eeAQUA || family == eeMANHAN || family == eeGHOMA);
4599 }
4600
4601 562 bool enemy::canmove_old(int32_t ndir,zfix s,int32_t special,int32_t dx1,int32_t dy1,int32_t dx2,int32_t dy2)
4602 {
4603 bool ok;
4604 562 int32_t dx = 0, dy = 0;
4605 562 int32_t sv = 8;
4606
4607 //Why is this here??? Why is it needed???
4608 562 s += 0.5; // Make the ints round; doesn't seem to cause any problems.
4609
4610
8/9
✓ Branch 0 taken 69 times.
✓ Branch 1 taken 51 times.
✓ Branch 2 taken 47 times.
✓ Branch 3 taken 85 times.
✓ Branch 4 taken 94 times.
✓ Branch 5 taken 78 times.
✓ Branch 6 taken 57 times.
✓ Branch 7 taken 81 times.
✗ Branch 8 not taken.
562 switch(ndir)
4611 {
4612 case 8:
4613 case up:
4614
3/4
✓ Branch 0 taken 38 times.
✓ Branch 1 taken 31 times.
✓ Branch 2 taken 38 times.
✗ Branch 3 not taken.
69 if(canfall(id) && isSideViewGravity())
4615 return false;
4616
4617 69 dy = dy1-s;
4618
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 69 times.
69 special = (special==spw_clipbottomright)?spw_none:special;
4619
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 69 times.
69 ok = !m_walkflag_old(x,y+dy,special, x, y) && !flyerblocked(x,y+dy, special);
4620 69 break;
4621
4622 case 12:
4623 case down:
4624
3/4
✓ Branch 0 taken 31 times.
✓ Branch 1 taken 20 times.
✓ Branch 2 taken 31 times.
✗ Branch 3 not taken.
51 if(canfall(id) && isSideViewGravity())
4625 return false;
4626
4627 51 dy = dy2+s;
4628
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 51 times.
51 ok = !m_walkflag_old(x,y+dy,special, x, y) && !flyerblocked(x,y+dy, special);
4629 51 break;
4630
4631 case 14:
4632 case left:
4633 47 dx = dx1-s;
4634 47 sv = ((isSideViewGravity())?7:8);
4635
2/4
✓ Branch 0 taken 47 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 47 times.
47 special = (special==spw_clipbottomright||special==spw_clipright)?spw_none:special;
4636
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 45 times.
47 ok = !m_walkflag_old(x+dx,y+sv,special, x, y) && !flyerblocked(x+dx,y+8, special);
4637 47 break;
4638
4639 case 10:
4640 case right:
4641 85 dx = dx2+s;
4642 85 sv = ((isSideViewGravity())?7:8);
4643
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 79 times.
85 ok = !m_walkflag_old(x+dx,y+sv,special, x, y) && !flyerblocked(x+dx,y+8, special);
4644 85 break;
4645
4646 case 9:
4647 case r_up:
4648 94 dx = dx2+s;
4649 94 dy = dy1-s;
4650
3/4
✓ Branch 0 taken 94 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 93 times.
✓ Branch 3 taken 1 times.
187 ok = !m_walkflag_old(x,y+dy,special, x, y) && !m_walkflag_old(x+dx,y+sv,special, x, y) &&
4651
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 93 times.
93 !flyerblocked(x,y+dy, special) && !flyerblocked(x+dx,y+8, special);
4652 94 break;
4653
4654 case 11:
4655 case r_down:
4656 78 dx = dx2+s;
4657 78 dx = dy2+s;
4658
3/4
✓ Branch 0 taken 78 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 77 times.
✓ Branch 3 taken 1 times.
155 ok = !m_walkflag_old(x,y+dy,special, x, y) && !m_walkflag_old(x+dx,y+sv,special, x, y) &&
4659
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 77 times.
77 !flyerblocked(x,y+dy, special) && !flyerblocked(x+dx,y+8, special);
4660 78 break;
4661
4662 case 13:
4663 case l_down:
4664 57 dx = dx1-s;
4665 57 dy = dy2+s;
4666
3/4
✓ Branch 0 taken 55 times.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 55 times.
✗ Branch 3 not taken.
112 ok = !m_walkflag_old(x,y+dy,special, x, y) && !m_walkflag_old(x+dx,y+sv,special, x, y) &&
4667
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 55 times.
55 !flyerblocked(x,y+dy, special) && !flyerblocked(x+dx,y+8, special);
4668 57 break;
4669
4670 case 15:
4671 case l_up:
4672 81 dx = dx1-s;
4673 81 dy = dy1-s;
4674
3/4
✓ Branch 0 taken 81 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 80 times.
✓ Branch 3 taken 1 times.
161 ok = !m_walkflag_old(x,y+dy,special, x, y) && !m_walkflag_old(x+dx,y+sv,special, x, y) &&
4675
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 80 times.
80 !flyerblocked(x,y+dy, special) && !flyerblocked(x+dx,y+8, special);
4676 81 break;
4677
4678 default:
4679 db=99;
4680 return true;
4681 }
4682
4683 562 return ok;
4684 562 }
4685
4686
4687
4688
4689 // returns true if next step is ok, false if there is something there
4690 7325199 bool enemy::canmove(int32_t ndir,zfix s,int32_t special,int32_t dx1,int32_t dy1,int32_t dx2,int32_t dy2, bool kb)
4691 {
4692 7325199 bool ok = false; //initialise the var, son't just declare it
4693 7325199 int32_t dx = 0, dy = 0;
4694 7325199 int32_t sv = 8;
4695 7325199 int32_t tries = 2; int32_t try_x = 0; int32_t try_y = 0;
4696 //Why is this here??? Why is it needed???
4697 7325199 s += 0.5; // Make the ints round; doesn't seem to cause any problems.
4698
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7325199 times.
7325199 int32_t usexoffs = (SIZEflags&OVERRIDE_HIT_X_OFFSET) ? hxofs : 0;
4699
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7325199 times.
7325199 int32_t useyoffs = (SIZEflags&OVERRIDE_HIT_Y_OFFSET) ? hyofs : 0;
4700
2/2
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 7325186 times.
7325199 int32_t usewid = (SIZEflags&OVERRIDE_HIT_WIDTH) ? hit_width : 16;
4701
2/2
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 7325186 times.
7325199 int32_t usehei = (SIZEflags&OVERRIDE_HIT_HEIGHT) ? hit_height : 16;
4702 7325199 bool offgrid = OFFGRID_ENEMY;
4703
2/2
✓ Branch 0 taken 7291 times.
✓ Branch 1 taken 7317908 times.
7325199 if(!offgrid)
4704 {
4705 //Enemies smaller than 1-tile must act as 1-tile large, if off-grid movement is disabled.
4706
1/2
✓ Branch 0 taken 7317908 times.
✗ Branch 1 not taken.
7317908 if(usehei<16)usehei=16;
4707
1/2
✓ Branch 0 taken 7317908 times.
✗ Branch 1 not taken.
7317908 if(usewid<16)usewid=16;
4708 7317908 }
4709
9/9
✓ Branch 0 taken 1327873 times.
✓ Branch 1 taken 1102917 times.
✓ Branch 2 taken 1221995 times.
✓ Branch 3 taken 1212911 times.
✓ Branch 4 taken 536645 times.
✓ Branch 5 taken 638123 times.
✓ Branch 6 taken 600184 times.
✓ Branch 7 taken 564898 times.
✓ Branch 8 taken 119653 times.
7325199 switch(ndir) //need to check every 8 pixels between two points
4710 {
4711 case 8:
4712 case up:
4713 {
4714
4/4
✓ Branch 0 taken 150619 times.
✓ Branch 1 taken 1177254 times.
✓ Branch 2 taken 150029 times.
✓ Branch 3 taken 590 times.
1327873 if(enemycanfall(id) && isSideViewGravity())
4715 590 return false;
4716
4717 1327283 dy = dy1-s;
4718
2/2
✓ Branch 0 taken 480 times.
✓ Branch 1 taken 1326803 times.
1327283 special = (special==spw_clipbottomright)?spw_none:special;
4719 1327283 tries = usewid/(offgrid ? 8 : 16);
4720 //Z_eventlog("Trying move UP, dy=%d,usewid=%d,usehei=%d\n",int32_t(dy),usewid,usehei);
4721
2/2
✓ Branch 0 taken 1127175 times.
✓ Branch 1 taken 1327933 times.
2455108 for ( ; tries > 0; --tries )
4722 {
4723
2/2
✓ Branch 0 taken 197488 times.
✓ Branch 1 taken 1130445 times.
1327933 ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy,special, ndir, x+usexoffs+try_x, y+useyoffs, kb) && !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy, special,kb);
4724 1327933 try_x += (offgrid ? 8 : 16);
4725
2/2
✓ Branch 0 taken 1127825 times.
✓ Branch 1 taken 200108 times.
1327933 if (!ok) break;
4726 1127825 }
4727
2/2
✓ Branch 0 taken 1127175 times.
✓ Branch 1 taken 200108 times.
1327283 if(!ok) break;
4728
1/2
✓ Branch 0 taken 1127175 times.
✗ Branch 1 not taken.
1127175 if((usewid%16)>0) //Uneven width
4729 {
4730 ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy,special, ndir, x+usexoffs+usewid-1, y+useyoffs, kb) && !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy, special,kb);
4731 }
4732 1127175 break;
4733 }
4734 case 12:
4735 case down:
4736 {
4737
4/4
✓ Branch 0 taken 180547 times.
✓ Branch 1 taken 922370 times.
✓ Branch 2 taken 179859 times.
✓ Branch 3 taken 688 times.
1102917 if(enemycanfall(id) && isSideViewGravity())
4738 688 return false;
4739
4740 1102229 dy = dy2+s;
4741 1102229 tries = usewid/(offgrid ? 8 : 16);
4742 //Z_eventlog("Trying move DOWN, dy=%d,usewid=%d,usehei=%d\n",int32_t(dy),usewid,usehei);
4743
2/2
✓ Branch 0 taken 896238 times.
✓ Branch 1 taken 1103013 times.
1999251 for ( ; tries > 0; --tries )
4744 {
4745
3/4
✓ Branch 0 taken 205243 times.
✓ Branch 1 taken 897770 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 897770 times.
1103013 ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy,special, ndir, x+usexoffs+try_x, y+useyoffs, kb) && !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy+zc_max(usehei-16,0), special,kb);
4746 1103013 try_x += (offgrid ? 8 : 16);
4747
2/2
✓ Branch 0 taken 897022 times.
✓ Branch 1 taken 205991 times.
1103013 if (!ok) break;
4748 897022 }
4749
2/2
✓ Branch 0 taken 896238 times.
✓ Branch 1 taken 205991 times.
1102229 if(!ok) break;
4750
1/2
✓ Branch 0 taken 896238 times.
✗ Branch 1 not taken.
896238 if((usewid%16)>0) //Uneven width
4751 {
4752 ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy,special, ndir, x+usexoffs+usewid-1, y+useyoffs, kb) && !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy+zc_max(usehei-16,0), special,kb);
4753 }
4754 896238 break;
4755 }
4756 case 14:
4757 case left:
4758 {
4759 1221995 dx = dx1-s;
4760 1221995 sv = ((isSideViewGravity())?7:0);
4761
4/4
✓ Branch 0 taken 1221372 times.
✓ Branch 1 taken 623 times.
✓ Branch 2 taken 1768 times.
✓ Branch 3 taken 1219604 times.
1221995 special = (special==spw_clipbottomright||special==spw_clipright)?spw_none:special;
4762 1221995 tries = usehei/(offgrid ? 8 : 16);
4763 //Z_eventlog("Trying move LEFT, dx=%d,usewid=%d,usehei=%d\n",int32_t(dx),usewid,usehei);
4764
2/2
✓ Branch 0 taken 1023070 times.
✓ Branch 1 taken 1222912 times.
2245982 for ( ; tries > 0; --tries )
4765 {
4766
2/2
✓ Branch 0 taken 197742 times.
✓ Branch 1 taken 1025170 times.
1222912 ok = !m_walkflag(x+usexoffs+dx,y+useyoffs+try_y+sv,special, ndir, x+usexoffs, y+useyoffs+try_y, kb) && !flyerblocked(x+usexoffs+dx,y+8+useyoffs+try_y, special,kb);
4767 1222912 try_y += (offgrid ? 8 : 16);
4768
2/2
✓ Branch 0 taken 1023987 times.
✓ Branch 1 taken 198925 times.
1222912 if (!ok) break;
4769 1023987 }
4770
2/2
✓ Branch 0 taken 1023070 times.
✓ Branch 1 taken 198925 times.
1221995 if(!ok) break;
4771
1/2
✓ Branch 0 taken 1023070 times.
✗ Branch 1 not taken.
1023070 if((usehei%16)>0) //Uneven height
4772 {
4773 ok = !m_walkflag(x+usexoffs+dx,y+useyoffs+usehei-1+sv,special, ndir, x+usexoffs, y+useyoffs+usehei-1, kb) && !flyerblocked(x+usexoffs+dx,y+8+useyoffs+usehei-1, special,kb);
4774 }
4775 1023070 break;
4776 }
4777 case 10:
4778 case right:
4779 {
4780 1212911 dx = dx2+s;
4781 1212911 sv = ((isSideViewGravity())?7:0);
4782 1212911 tries = usehei/(offgrid ? 8 : 16);
4783 //Z_eventlog("Trying move RIGHT, dx=%d,usewid=%d,usehei=%d\n",int32_t(dx),usewid,usehei);
4784
2/2
✓ Branch 0 taken 1024814 times.
✓ Branch 1 taken 1213805 times.
2238619 for ( ; tries > 0; --tries )
4785 {
4786
3/4
✓ Branch 0 taken 186744 times.
✓ Branch 1 taken 1027061 times.
✓ Branch 2 taken 1027061 times.
✗ Branch 3 not taken.
1213805 ok = !m_walkflag(x+usexoffs+dx,y+useyoffs+try_y+sv,special, ndir, x+usexoffs, y+useyoffs+try_y, kb) && !flyerblocked(x+usexoffs+dx+zc_max(usewid-16,0),y+8+useyoffs+try_y, special,kb);
4787 1213805 try_y += (offgrid ? 8 : 16);
4788
2/2
✓ Branch 0 taken 1025708 times.
✓ Branch 1 taken 188097 times.
1213805 if (!ok) break;
4789 1025708 }
4790
2/2
✓ Branch 0 taken 1024814 times.
✓ Branch 1 taken 188097 times.
1212911 if(!ok) break;
4791
1/2
✓ Branch 0 taken 1024814 times.
✗ Branch 1 not taken.
1024814 if((usehei%16)>0) //Uneven height
4792 {
4793 ok = !m_walkflag(x+usexoffs+dx,y+useyoffs+usehei-1+sv,special, ndir, x+usexoffs, y+useyoffs+usehei-1, kb) && !flyerblocked(x+usexoffs+dx+zc_max(usewid-16,0),y+8+useyoffs+usehei-1, special,kb);
4794 }
4795 1024814 break;
4796 }
4797 case 9:
4798 case r_up:
4799 {
4800 536645 dx = dx2+s;
4801 536645 dy = dy1-s;
4802 536645 int32_t tries_x = usewid/(offgrid ? 8 : 16);
4803 536645 sv = ((isSideViewGravity())?7:0);
4804
2/2
✓ Branch 0 taken 519643 times.
✓ Branch 1 taken 536645 times.
1056288 for ( ; tries_x > 0; --tries_x )
4805 {
4806 536645 int32_t tries_y = usehei/(offgrid ? 8 : 16);
4807 536645 try_y = 0;
4808
2/2
✓ Branch 0 taken 519643 times.
✓ Branch 1 taken 536645 times.
1056288 for ( ; tries_y > 0; --tries_y )
4809 {
4810
4/4
✓ Branch 0 taken 528401 times.
✓ Branch 1 taken 8244 times.
✓ Branch 2 taken 522980 times.
✓ Branch 3 taken 5421 times.
1059625 ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy+try_y,special,ndir, x+usexoffs+try_x, y+useyoffs+try_y, kb) && !m_walkflag(x+usexoffs+dx+try_x,y+useyoffs+sv+try_y,special,ndir, x+usexoffs+try_x, y+useyoffs+try_y, kb) &&
4811
2/2
✓ Branch 0 taken 2392 times.
✓ Branch 1 taken 520588 times.
522980 !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy+try_y, special,kb) && !flyerblocked(x+usexoffs+dx+try_x,y+useyoffs+8+try_y, special,kb);
4812 536645 try_y += (offgrid ? 8 : 16);
4813
2/2
✓ Branch 0 taken 519643 times.
✓ Branch 1 taken 17002 times.
536645 if (!ok) break;
4814 519643 }
4815
2/2
✓ Branch 0 taken 519643 times.
✓ Branch 1 taken 17002 times.
536645 if (!ok) break;
4816
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 519643 times.
519643 if((usehei%16)>0) //Uneven height
4817 {
4818 ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy+usehei-1,special,ndir, x+usexoffs+try_x, y+useyoffs+usehei-1, kb) && !m_walkflag(x+usexoffs+dx+try_x,y+useyoffs+sv+usehei-1,special,ndir, x+usexoffs+try_x, y+useyoffs+usehei-1, kb) &&
4819 !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy+usehei-1, special,kb) && !flyerblocked(x+usexoffs+dx+try_x,y+useyoffs+8+usehei-1, special,kb);
4820 }
4821 519643 try_x += (offgrid ? 8 : 16);
4822 519643 }
4823
2/2
✓ Branch 0 taken 519643 times.
✓ Branch 1 taken 17002 times.
536645 if(!ok) break;
4824
1/2
✓ Branch 0 taken 519643 times.
✗ Branch 1 not taken.
519643 if((usewid%16)>0) //Uneven width
4825 {
4826 int32_t tries_y = usehei/(offgrid ? 8 : 16);
4827 try_y = 0;
4828 for ( ; tries_y > 0; --tries_y )
4829 {
4830 ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy+try_y,special,ndir, x+usexoffs+usewid-1, y+useyoffs+try_y, kb) && !m_walkflag(x+usexoffs+dx+usewid-1,y+useyoffs+sv+try_y,special,ndir, x+usexoffs+usewid-1, y+useyoffs+try_y, kb) &&
4831 !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy+try_y, special,kb) && !flyerblocked(x+usexoffs+dx+usewid-1,y+useyoffs+8+try_y, special,kb);
4832 try_y += (offgrid ? 8 : 16);
4833 if (!ok) break;
4834 }
4835 if (!ok) break;
4836 if((usehei%16)>0) //Uneven height
4837 {
4838 ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy+usehei-1,special,ndir, x+usexoffs+usewid-1, y+useyoffs+usehei-1, kb) && !m_walkflag(x+usexoffs+dx+usewid-1,y+useyoffs+sv+usehei-1,special,ndir, x+usexoffs+usewid-1, y+useyoffs+usehei-1, kb) &&
4839 !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy+usehei-1, special,kb) && !flyerblocked(x+usexoffs+dx+usewid-1,y+useyoffs+8+usehei-1, special,kb);
4840 }
4841 }
4842 519643 break;
4843 }
4844 case 11:
4845 case r_down:
4846 {
4847 638123 dx = dx2+s;
4848 638123 dx = dy2+s;
4849 638123 int32_t tries_x = usewid/(offgrid ? 8 : 16);
4850 //sv = ((isSideViewGravity())?7:0);
4851
2/2
✓ Branch 0 taken 622773 times.
✓ Branch 1 taken 638123 times.
1260896 for ( ; tries_x > 0; --tries_x )
4852 {
4853 638123 int32_t tries_y = usehei/(offgrid ? 8 : 16);
4854 638123 try_y = 0;
4855
2/2
✓ Branch 0 taken 622773 times.
✓ Branch 1 taken 638123 times.
1260896 for ( ; tries_y > 0; --tries_y )
4856 {
4857
4/4
✓ Branch 0 taken 636612 times.
✓ Branch 1 taken 1511 times.
✓ Branch 2 taken 623840 times.
✓ Branch 3 taken 12772 times.
1261963 ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy+try_y,special,ndir, x+usexoffs+try_x, y+useyoffs+try_y, kb) && !m_walkflag(x+usexoffs+dx+try_x,y+useyoffs+sv+try_y,special,ndir, x+usexoffs+try_x, y+useyoffs+try_y, kb) &&
4858
2/2
✓ Branch 0 taken 106 times.
✓ Branch 1 taken 623734 times.
623840 !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy+try_y, special,kb) && !flyerblocked(x+usexoffs+dx+try_x,y+useyoffs+8+try_y, special,kb);
4859 638123 try_y += (offgrid ? 8 : 16);
4860
2/2
✓ Branch 0 taken 622773 times.
✓ Branch 1 taken 15350 times.
638123 if (!ok) break;
4861 622773 }
4862
2/2
✓ Branch 0 taken 622773 times.
✓ Branch 1 taken 15350 times.
638123 if (!ok) break;
4863
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 622773 times.
622773 if((usehei%16)>0) //Uneven height
4864 {
4865 ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy+usehei-1,special,ndir, x+usexoffs+try_x, y+useyoffs+usehei-1, kb) && !m_walkflag(x+usexoffs+dx+try_x,y+useyoffs+sv+usehei-1,special,ndir, x+usexoffs+try_x, y+useyoffs+usehei-1, kb) &&
4866 !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy+usehei-1, special,kb) && !flyerblocked(x+usexoffs+dx+try_x,y+useyoffs+8+usehei-1, special,kb);
4867 }
4868 622773 try_x += (offgrid ? 8 : 16);
4869 622773 }
4870
2/2
✓ Branch 0 taken 622773 times.
✓ Branch 1 taken 15350 times.
638123 if(!ok) break;
4871
1/2
✓ Branch 0 taken 622773 times.
✗ Branch 1 not taken.
622773 if((usewid%16)>0) //Uneven width
4872 {
4873 int32_t tries_y = usehei/(offgrid ? 8 : 16);
4874 try_y = 0;
4875 for ( ; tries_y > 0; --tries_y )
4876 {
4877 ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy+try_y,special,ndir, x+usexoffs+usewid-1, y+useyoffs+try_y, kb) && !m_walkflag(x+usexoffs+dx+usewid-1,y+useyoffs+sv+try_y,special,ndir, x+usexoffs+usewid-1, y+useyoffs+try_y, kb) &&
4878 !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy+try_y, special,kb) && !flyerblocked(x+usexoffs+dx+usewid-1,y+useyoffs+8+try_y, special,kb);
4879 try_y += (offgrid ? 8 : 16);
4880 if (!ok) break;
4881 }
4882 if (!ok) break;
4883 if((usehei%16)>0) //Uneven height
4884 {
4885 ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy+usehei-1,special,ndir, x+usexoffs+usewid-1, y+useyoffs+usehei-1, kb) && !m_walkflag(x+usexoffs+dx+usewid-1,y+useyoffs+sv+usehei-1,special,ndir, x+usexoffs+usewid-1, y+useyoffs+usehei-1, kb) &&
4886 !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy+usehei-1, special,kb) && !flyerblocked(x+usexoffs+dx+usewid-1,y+useyoffs+8+usehei-1, special,kb);
4887 }
4888 }
4889 622773 break;
4890 }
4891 case 13:
4892 case l_down:
4893 {
4894 600184 dx = dx1-s;
4895 600184 dy = dy2+s;
4896 600184 int32_t tries_x = usewid/(offgrid ? 8 : 16);
4897 //sv = ((isSideViewGravity())?7:0);
4898
2/2
✓ Branch 0 taken 583146 times.
✓ Branch 1 taken 600184 times.
1183330 for ( ; tries_x > 0; --tries_x )
4899 {
4900 600184 int32_t tries_y = usehei/(offgrid ? 8 : 16);
4901 600184 try_y = 0;
4902
2/2
✓ Branch 0 taken 583146 times.
✓ Branch 1 taken 600184 times.
1183330 for ( ; tries_y > 0; --tries_y )
4903 {
4904
4/4
✓ Branch 0 taken 588277 times.
✓ Branch 1 taken 11907 times.
✓ Branch 2 taken 584012 times.
✓ Branch 3 taken 4265 times.
1184196 ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy+try_y,special,ndir, x+usexoffs+try_x, y+useyoffs+try_y, kb) && !m_walkflag(x+usexoffs+dx+try_x,y+useyoffs+sv+try_y,special,ndir, x+usexoffs+try_x, y+useyoffs+try_y, kb) &&
4905
2/2
✓ Branch 0 taken 568 times.
✓ Branch 1 taken 583444 times.
584012 !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy+try_y, special,kb) && !flyerblocked(x+usexoffs+dx+try_x,y+useyoffs+8+try_y, special,kb);
4906 600184 try_y += (offgrid ? 8 : 16);
4907
2/2
✓ Branch 0 taken 583146 times.
✓ Branch 1 taken 17038 times.
600184 if (!ok) break;
4908 583146 }
4909
2/2
✓ Branch 0 taken 583146 times.
✓ Branch 1 taken 17038 times.
600184 if (!ok) break;
4910
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 583146 times.
583146 if((usehei%16)>0) //Uneven height
4911 {
4912 ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy+usehei-1,special,ndir, x+usexoffs+try_x, y+useyoffs+usehei-1, kb) && !m_walkflag(x+usexoffs+dx+try_x,y+useyoffs+sv+usehei-1,special,ndir, x+usexoffs+try_x, y+useyoffs+usehei-1, kb) &&
4913 !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy+usehei-1, special,kb) && !flyerblocked(x+usexoffs+dx+try_x,y+useyoffs+8+usehei-1, special,kb);
4914 }
4915 583146 try_x += (offgrid ? 8 : 16);
4916 583146 }
4917
2/2
✓ Branch 0 taken 583146 times.
✓ Branch 1 taken 17038 times.
600184 if(!ok) break;
4918
1/2
✓ Branch 0 taken 583146 times.
✗ Branch 1 not taken.
583146 if((usewid%16)>0) //Uneven width
4919 {
4920 int32_t tries_y = usehei/(offgrid ? 8 : 16);
4921 try_y = 0;
4922 for ( ; tries_y > 0; --tries_y )
4923 {
4924 ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy+try_y,special,ndir, x+usexoffs+usewid-1, y+useyoffs+try_y, kb) && !m_walkflag(x+usexoffs+dx+usewid-1,y+useyoffs+sv+try_y,special,ndir, x+usexoffs+usewid-1, y+useyoffs+try_y, kb) &&
4925 !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy+try_y, special,kb) && !flyerblocked(x+usexoffs+dx+usewid-1,y+useyoffs+8+try_y, special,kb);
4926 try_y += (offgrid ? 8 : 16);
4927 if (!ok) break;
4928 }
4929 if (!ok) break;
4930 if((usehei%16)>0) //Uneven height
4931 {
4932 ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy+usehei-1,special,ndir, x+usexoffs+usewid-1, y+useyoffs+usehei-1, kb) && !m_walkflag(x+usexoffs+dx+usewid-1,y+useyoffs+sv+usehei-1,special,ndir, x+usexoffs+usewid-1, y+useyoffs+usehei-1, kb) &&
4933 !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy+usehei-1, special,kb) && !flyerblocked(x+usexoffs+dx+usewid-1,y+useyoffs+8+usehei-1, special,kb);
4934 }
4935 }
4936 583146 break;
4937 }
4938 case 15:
4939 case l_up:
4940 {
4941 564898 dx = dx1-s;
4942 564898 dy = dy1-s;
4943 564898 int32_t tries_x = usewid/(offgrid ? 8 : 16);
4944 564898 sv = ((isSideViewGravity())?7:0);
4945
2/2
✓ Branch 0 taken 549004 times.
✓ Branch 1 taken 564898 times.
1113902 for ( ; tries_x > 0; --tries_x )
4946 {
4947 564898 int32_t tries_y = usehei/(offgrid ? 8 : 16);
4948 564898 try_y = 0;
4949
2/2
✓ Branch 0 taken 549004 times.
✓ Branch 1 taken 564898 times.
1113902 for ( ; tries_y > 0; --tries_y )
4950 {
4951
4/4
✓ Branch 0 taken 556265 times.
✓ Branch 1 taken 8633 times.
✓ Branch 2 taken 552308 times.
✓ Branch 3 taken 3957 times.
1117206 ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy+try_y,special,ndir, x+usexoffs+try_x, y+useyoffs+try_y, kb) && !m_walkflag(x+usexoffs+dx+try_x,y+useyoffs+sv+try_y,special,ndir, x+usexoffs+try_x, y+useyoffs+try_y, kb) &&
4952
2/2
✓ Branch 0 taken 2439 times.
✓ Branch 1 taken 549869 times.
552308 !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy+try_y, special,kb) && !flyerblocked(x+usexoffs+dx+try_x,y+useyoffs+8+try_y, special,kb);
4953 564898 try_y += (offgrid ? 8 : 16);
4954
2/2
✓ Branch 0 taken 549004 times.
✓ Branch 1 taken 15894 times.
564898 if (!ok) break;
4955 549004 }
4956
2/2
✓ Branch 0 taken 549004 times.
✓ Branch 1 taken 15894 times.
564898 if (!ok) break;
4957
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 549004 times.
549004 if((usehei%16)>0) //Uneven height
4958 {
4959 ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy+usehei-1,special,ndir, x+usexoffs+try_x, y+useyoffs+usehei-1, kb) && !m_walkflag(x+usexoffs+dx+try_x,y+useyoffs+sv+usehei-1,special,ndir, x+usexoffs+try_x, y+useyoffs+usehei-1, kb) &&
4960 !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy+usehei-1, special,kb) && !flyerblocked(x+usexoffs+dx+try_x,y+useyoffs+8+usehei-1, special,kb);
4961 }
4962 549004 try_x += (offgrid ? 8 : 16);
4963 549004 }
4964
2/2
✓ Branch 0 taken 549004 times.
✓ Branch 1 taken 15894 times.
564898 if(!ok) break;
4965
1/2
✓ Branch 0 taken 549004 times.
✗ Branch 1 not taken.
549004 if((usewid%16)>0) //Uneven width
4966 {
4967 int32_t tries_y = usehei/(offgrid ? 8 : 16);
4968 try_y = 0;
4969 for ( ; tries_y > 0; --tries_y )
4970 {
4971 ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy+try_y,special,ndir, x+usexoffs+usewid-1, y+useyoffs+try_y, kb) && !m_walkflag(x+usexoffs+dx+usewid-1,y+useyoffs+sv+try_y,special,ndir, x+usexoffs+usewid-1, y+useyoffs+try_y, kb) &&
4972 !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy+try_y, special,kb) && !flyerblocked(x+usexoffs+dx+usewid-1,y+useyoffs+8+try_y, special,kb);
4973 try_y += (offgrid ? 8 : 16);
4974 if (!ok) break;
4975 }
4976 if (!ok) break;
4977 if((usehei%16)>0) //Uneven height
4978 {
4979 ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy+usehei-1,special,ndir, x+usexoffs+usewid-1, y+useyoffs+usehei-1, kb) && !m_walkflag(x+usexoffs+dx+usewid-1,y+useyoffs+sv+usehei-1,special,ndir, x+usexoffs+usewid-1, y+useyoffs+usehei-1, kb) &&
4980 !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy+usehei-1, special,kb) && !flyerblocked(x+usexoffs+dx+usewid-1,y+useyoffs+8+usehei-1, special,kb);
4981 }
4982 }
4983 549004 break;
4984 }
4985 default:
4986 119653 db=99;
4987 119653 return true;
4988 }
4989 //Z_eventlog("\n");
4990 7204268 return ok;
4991 7325199 }
4992
4993
4994 4624263 bool enemy::canmove(int32_t ndir,zfix s,int32_t special, bool kb)
4995 {
4996
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4624263 times.
4624263 int32_t usewid = (SIZEflags&OVERRIDE_HIT_WIDTH) ? hit_width : 16;
4997
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4624263 times.
4624263 int32_t usehei = (SIZEflags&OVERRIDE_HIT_HEIGHT) ? hit_height : 16;
4998
1/2
✓ Branch 0 taken 4624263 times.
✗ Branch 1 not taken.
4624263 if (usewid % 16 != 0) usewid += (16 - (usewid%16));
4999
1/2
✓ Branch 0 taken 4624263 times.
✗ Branch 1 not taken.
4624263 if (usehei % 16 != 0) usehei += (16 - (usehei%16));
5000 4624263 --usewid;
5001 4624263 --usehei;
5002 4624263 return canmove(ndir,s,special,0,-8,usewid,usehei,kb);
5003 }
5004
5005 1243156 bool enemy::canmove(int32_t ndir,int32_t special, bool kb)
5006 {
5007 1243156 bool dodongo_move=true; //yes, it's an ugly hack, but we're going to rewrite everything later anyway - DN
5008
5009
4/4
✓ Branch 0 taken 6819 times.
✓ Branch 1 taken 1236337 times.
✓ Branch 2 taken 5021 times.
✓ Branch 3 taken 1798 times.
1243156 if(special==spw_clipright&&ndir==right)
5010 {
5011 1798 dodongo_move=canmove(ndir,(zfix)1,special,0,-8,31,15,kb);
5012 1798 }
5013
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 1243151 times.
1243156 int32_t usewid = (SIZEflags&OVERRIDE_HIT_WIDTH) ? hit_width : 16;
5014
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 1243151 times.
1243156 int32_t usehei = (SIZEflags&OVERRIDE_HIT_HEIGHT) ? hit_height : 16;
5015
1/2
✓ Branch 0 taken 1243156 times.
✗ Branch 1 not taken.
1243156 if (usewid % 16 != 0) usewid += (16 - (usewid%16));
5016
1/2
✓ Branch 0 taken 1243156 times.
✗ Branch 1 not taken.
1243156 if (usehei % 16 != 0) usehei += (16 - (usehei%16));
5017 1243156 --usewid;
5018 1243156 --usehei;
5019
2/2
✓ Branch 0 taken 716881 times.
✓ Branch 1 taken 526275 times.
1243156 return canmove(ndir,(zfix)1,special,0,-8,usewid,usehei,kb)&&dodongo_move;
5020 }
5021
5022 136202 bool enemy::canmove(int32_t ndir, bool kb)
5023 {
5024 136202 return canmove(ndir,(zfix)1,spw_none,0,-8,15,15,kb);
5025 }
5026
5027 // 8-directional
5028 562 void enemy::newdir_8_old(int32_t newrate,int32_t newhoming,int32_t special,int32_t dx1,int32_t dy1,int32_t dx2,int32_t dy2)
5029 {
5030 562 int32_t ndir=0;
5031
5032 // can move straight, check if it wants to turn
5033
2/2
✓ Branch 0 taken 549 times.
✓ Branch 1 taken 13 times.
562 if(canmove_old(dir,step,special,dx1,dy1,dx2,dy2))
5034 {
5035
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 549 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
549 if(grumble && (zc_oldrand()&4)<grumble) //Homing
5036 {
5037 int32_t w = Lwpns.idFirst(wBait);
5038
5039 if(w>=0)
5040 {
5041 int32_t bx = Lwpns.spr(w)->x;
5042 int32_t by = Lwpns.spr(w)->y;
5043
5044 ndir = (bx<x) ? left : (bx!=x) ? right : 0;
5045
5046 if(abs(int32_t(y)-by)>14)
5047 {
5048 if(ndir>0) // Already left or right
5049 {
5050 // Making the diagonal directions
5051 ndir += (by<y) ? 2 : 4;
5052 }
5053 else
5054 {
5055 ndir = (by<y) ? up : down;
5056 }
5057 }
5058
5059 if(canmove(ndir,special,false))
5060 {
5061 dir=ndir;
5062 return;
5063 }
5064 }
5065 }
5066
5067 // Homing added.
5068
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 549 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
549 if(newhoming && (zc_oldrand()&255)<newhoming)
5069 {
5070 ndir = lined_up(8,true);
5071
5072 if(ndir>=0 && canmove(ndir,special,false))
5073 {
5074 dir=ndir;
5075 }
5076
5077 return;
5078 }
5079
5080 549 int32_t r=zc_oldrand();
5081
5082
2/4
✓ Branch 0 taken 549 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 549 times.
549 if(newrate>0 && !(r%newrate))
5083 {
5084 549 ndir = ((dir+((r&64)?-1:1))&7)+8;
5085 549 int32_t ndir2=((dir+((r&64)?1:-1))&7)+8;
5086
5087
2/2
✓ Branch 0 taken 525 times.
✓ Branch 1 taken 24 times.
549 if(canmove(ndir,step,special,dx1,dy1,dx2,dy2,false))
5088 525 dir=ndir;
5089
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 19 times.
24 else if(canmove(ndir2,step,special,dx1,dy1,dx2,dy2,false))
5090 19 dir=ndir2;
5091
5092
3/4
✓ Branch 0 taken 525 times.
✓ Branch 1 taken 24 times.
✓ Branch 2 taken 525 times.
✗ Branch 3 not taken.
549 if(dir==ndir && (newrate>=4)) // newrate>=4, otherwise movement is biased toward upper-left
5093 // due to numerous lost fractional components. -L
5094 {
5095 x.doFloor();
5096 y.doFloor();
5097 }
5098 549 }
5099
5100 549 return;
5101 }
5102
5103 // can't move straight, must turn
5104 13 int32_t i=0;
5105
5106
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 20 times.
20 for(; i<32; i++) // Try random dir
5107 {
5108 20 ndir=(zc_oldrand()&7)+8;
5109
5110
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 13 times.
20 if(canmove(ndir,step,special,dx1,dy1,dx2,dy2,false))
5111 13 break;
5112 7 }
5113
5114
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if(i==32)
5115 {
5116 for(ndir=8; ndir<16; ndir++)
5117 {
5118 if(canmove(ndir,step,special,dx1,dy1,dx2,dy2,false))
5119 goto ok;
5120 }
5121
5122 ndir = (isSideViewGravity()) ? (zc_oldrand()&1 ? left : right) : -1; // Sideview enemies get trapped if their dir becomes -1
5123 }
5124
5125 ok:
5126 13 dir=ndir;
5127 13 x.doFloor();
5128 13 y.doFloor();
5129 562 }
5130
5131 577113 void enemy::newdir_8(int32_t newrate,int32_t newhoming,int32_t special,int32_t dx1,int32_t dy1,int32_t dx2,int32_t dy2)
5132 {
5133 577113 int32_t ndir=0;
5134
5135 // can move straight, check if it wants to turn
5136
2/2
✓ Branch 0 taken 544558 times.
✓ Branch 1 taken 32555 times.
577113 if(canmove(dir,step,special,dx1,dy1,dx2,dy2,false))
5137 {
5138
4/4
✓ Branch 0 taken 207 times.
✓ Branch 1 taken 544351 times.
✓ Branch 2 taken 106 times.
✓ Branch 3 taken 101 times.
544558 if(grumble && (zc_oldrand()&4)<abs(grumble)) //Homing
5139 {
5140 101 int32_t i = Lwpns.idFirst(wBait);
5141
1/2
✓ Branch 0 taken 101 times.
✗ Branch 1 not taken.
101 if(i >= 0) //idfirst returns -1 if it can't find any
5142 {
5143 weapon *w = (weapon*)Lwpns.spr(i);
5144 if (get_qr(qr_FIND_CLOSEST_BAIT))
5145 {
5146 int32_t currentrange;
5147 if (distance(x, y, w->x, w->y) < w->misc2 || w->misc2 == 0) currentrange = distance(x, y, w->x, w->y);
5148 else currentrange = -1;
5149 int curid = i;
5150 ++i; //increment beforehand cause we just checked the first bait weapon and all others must be after it. ...otherwise it wouldn't be the first. -Deedee
5151 for(; i<Lwpns.Count(); ++i)
5152 {
5153 weapon *lw = (weapon*)Lwpns.spr(i);
5154 if (lw->id == wBait && distance(x, y, lw->x, lw->y) < currentrange && (distance(x, y, lw->x, lw->y) < lw->misc2 || lw->misc2 == 0))
5155 {
5156 currentrange = distance(x, y, lw->x, lw->y);
5157 curid = i;
5158 }
5159 }
5160 i = curid;
5161 if (currentrange == -1) i = -1;
5162 }
5163 else
5164 {
5165 if (!(distance(x, y, w->x, w->y) < w->misc2 || w->misc2 == 0)) i = -1;
5166 }
5167 if(i>=0)
5168 {
5169 int32_t bx = Lwpns.spr(i)->x;
5170 int32_t by = Lwpns.spr(i)->y;
5171
5172 ndir = (bx<x) ? left : (bx!=x) ? right : 0;
5173
5174 if(abs(int32_t(y)-by)>14)
5175 {
5176 if(ndir>0) // Already left or right
5177 {
5178 // Making the diagonal directions
5179 ndir += (by<y) ? 2 : 4;
5180 }
5181 else
5182 {
5183 ndir = (by<y) ? up : down;
5184 }
5185 }
5186 if (grumble < 0 || (itemsbuf[((weapon*)Lwpns.spr(i))->parentitem].flags & item_flag1)) ndir = oppositeDir[ndir];
5187 if(canmove(ndir,special,false))
5188 {
5189 dir=ndir;
5190 return;
5191 }
5192 }
5193 }
5194 101 }
5195
5196 // Homing added.
5197
4/4
✓ Branch 0 taken 29626 times.
✓ Branch 1 taken 514932 times.
✓ Branch 2 taken 15410 times.
✓ Branch 3 taken 14216 times.
544558 if(newhoming && (zc_oldrand()&255)<abs(newhoming))
5198 {
5199 14216 ndir = lined_up(8,true);
5200
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 14216 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
14216 if (newhoming < 0 && ndir >= 0) ndir = oppositeDir[ndir];
5201
4/4
✓ Branch 0 taken 9445 times.
✓ Branch 1 taken 4771 times.
✓ Branch 2 taken 3593 times.
✓ Branch 3 taken 5852 times.
14216 if(ndir>=0 && canmove(ndir,special,false))
5202 {
5203 5852 dir=ndir;
5204 5852 }
5205
5206 14216 return;
5207 }
5208
5209 530342 int32_t r=zc_oldrand();
5210
5211
4/4
✓ Branch 0 taken 338430 times.
✓ Branch 1 taken 191912 times.
✓ Branch 2 taken 178921 times.
✓ Branch 3 taken 159509 times.
530342 if(newrate>0 && !(r%newrate))
5212 {
5213 159509 ndir = ((dir+((r&64)?-1:1))&7)+8;
5214 159509 int32_t ndir2=((dir+((r&64)?1:-1))&7)+8;
5215
5216
2/2
✓ Branch 0 taken 153722 times.
✓ Branch 1 taken 5787 times.
159509 if(canmove(ndir,step,special,dx1,dy1,dx2,dy2,false))
5217 153722 dir=ndir;
5218
2/2
✓ Branch 0 taken 857 times.
✓ Branch 1 taken 4930 times.
5787 else if(canmove(ndir2,step,special,dx1,dy1,dx2,dy2,false))
5219 4930 dir=ndir2;
5220
5221
4/4
✓ Branch 0 taken 153722 times.
✓ Branch 1 taken 5787 times.
✓ Branch 2 taken 146396 times.
✓ Branch 3 taken 7326 times.
159509 if(dir==ndir && (newrate>=4)) // newrate>=4, otherwise movement is biased toward upper-left
5222 // due to numerous lost fractional components. -L
5223 {
5224 7326 x.doFloor();
5225 7326 y.doFloor();
5226 7326 }
5227 159509 }
5228
5229 530342 return;
5230 }
5231
5232 // can't move straight, must turn
5233 32555 int32_t i=0;
5234
5235
2/2
✓ Branch 0 taken 70 times.
✓ Branch 1 taken 60993 times.
61063 for(; i<32; i++) // Try random dir
5236 {
5237 60993 ndir=(zc_oldrand()&7)+8;
5238
5239
2/2
✓ Branch 0 taken 28508 times.
✓ Branch 1 taken 32485 times.
60993 if(canmove(ndir,step,special,dx1,dy1,dx2,dy2,false))
5240 32485 break;
5241 28508 }
5242
5243
2/2
✓ Branch 0 taken 32485 times.
✓ Branch 1 taken 70 times.
32608 if(i==32)
5244 {
5245
2/2
✓ Branch 0 taken 461 times.
✓ Branch 1 taken 53 times.
514 for(ndir=8; ndir<16; ndir++)
5246 {
5247
2/2
✓ Branch 0 taken 444 times.
✓ Branch 1 taken 17 times.
461 if(canmove(ndir,step,special,dx1,dy1,dx2,dy2,false))
5248 17 goto ok;
5249 444 }
5250
5251
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 53 times.
53 ndir = (isSideViewGravity()) ? (zc_oldrand()&1 ? left : right) : -1; // Sideview enemies get trapped if their dir becomes -1
5252 53 }
5253
5254 ok:
5255 32555 dir=ndir;
5256 32555 x.doFloor();
5257 32555 y.doFloor();
5258 577113 }
5259
5260 570638 void enemy::newdir_8(int32_t newrate,int32_t newhoming,int32_t special)
5261 {
5262 570638 newdir_8(newrate,newhoming,special,0,-8,15,15);
5263 570638 }
5264
5265 562 void enemy::newdir_8_old(int32_t newrate,int32_t newhoming,int32_t special)
5266 {
5267 562 newdir_8_old(newrate,newhoming,special,0,-8,15,15);
5268 562 }
5269
5270 // makes the enemy slide backwards when hit
5271 // sclk: first byte is clk, second byte is dir
5272 // makes the enemy slide backwards when hit
5273 // sclk: first byte is clk, second byte is dir
5274 15623459 int32_t enemy::slide()
5275 {
5276
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15623459 times.
15623459 if(script_knockback_clk!=0) //scripted knockback
5277 {
5278 sclk = 0;
5279 return 1; //scripted knockback ran
5280 }
5281
5/6
✓ Branch 0 taken 102071 times.
✓ Branch 1 taken 15521388 times.
✓ Branch 2 taken 7848 times.
✓ Branch 3 taken 94223 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 7848 times.
15623459 if(sclk==0 || (hp<=0 && !immortal))
5282 15529236 return 0;
5283
5284
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 94223 times.
94223 if(knockbackflags & FLAG_NOSLIDE)
5285 {
5286 sclk = 0;
5287 if(!OFFGRID_ENEMY)
5288 {
5289 //Fix to grid
5290 //x = (int32_t(x)+8)-((int32_t(x)+8)%16);
5291 //y = (int32_t(y)+8)-((int32_t(y)+8)%16);
5292 do_fix(x, 16, true);
5293 do_fix(y, 16, true);
5294 }
5295 return 0;
5296 }
5297
8/10
✓ Branch 0 taken 9551 times.
✓ Branch 1 taken 84672 times.
✓ Branch 2 taken 296 times.
✓ Branch 3 taken 9255 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 296 times.
✓ Branch 6 taken 7103 times.
✓ Branch 7 taken 2152 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 296 times.
94223 if((sclk&255)==16 && (get_qr(qr_OLD_ENEMY_KNOCKBACK_COLLISION) || knockbackSpeed!=4 ? !canmove(sclk>>8,(zfix) (dmisc2==e2tSPLITHIT ? 1 : 12),0,true) : !canmove(sclk>>8,(zfix) (dmisc2==e2tSPLITHIT ? 1 : knockbackSpeed),0,0,0,15,15,true)))
5298 {
5299 2152 sclk=0;
5300 2152 return 0;
5301 }
5302
5303 92071 --sclk;
5304
5305
5/5
✓ Branch 0 taken 1785 times.
✓ Branch 1 taken 10539 times.
✓ Branch 2 taken 12291 times.
✓ Branch 3 taken 31734 times.
✓ Branch 4 taken 35722 times.
92071 switch(sclk>>8)
5306 {
5307 case up:
5308 {
5309
4/4
✓ Branch 0 taken 1090 times.
✓ Branch 1 taken 9449 times.
✓ Branch 2 taken 7 times.
✓ Branch 3 taken 10532 times.
10539 if(y<=(dmisc2==e2tSPLITHIT ? 0 : (get_qr(qr_OLD_ENEMY_KNOCKBACK_COLLISION)?16:0))) //vires
5310 {
5311 7 sclk=0;
5312 7 return 0;
5313 }
5314
4/4
✓ Branch 0 taken 1090 times.
✓ Branch 1 taken 9442 times.
✓ Branch 2 taken 915 times.
✓ Branch 3 taken 175 times.
10532 if ( dmisc2==e2tSPLITHIT && !canmove(sclk>>8,(zfix)(4),0,true) ) { sclk=0; return 0; } //vires
5315
5316 10357 break;
5317 }
5318 case down:
5319 {
5320
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 12289 times.
12291 if(y>=(dmisc2==e2tSPLITHIT ? 150 : 160)) //was 160 --changed for vires bug.
5321 {
5322 2 sclk=0;
5323 2 return 0;
5324 }
5325
4/4
✓ Branch 0 taken 1069 times.
✓ Branch 1 taken 11220 times.
✓ Branch 2 taken 923 times.
✓ Branch 3 taken 146 times.
12289 if ( dmisc2==e2tSPLITHIT && !canmove(sclk>>8,(zfix)(4),0,true) ) { sclk=0; return 0; } //vires
5326
5327 12143 break;
5328 }
5329 case left:
5330 {
5331
4/4
✓ Branch 0 taken 2354 times.
✓ Branch 1 taken 29380 times.
✓ Branch 2 taken 13 times.
✓ Branch 3 taken 31721 times.
31734 if(x<=(dmisc2==e2tSPLITHIT ? 0 : (get_qr(qr_OLD_ENEMY_KNOCKBACK_COLLISION)?16:0)))
5332 {
5333 13 sclk=0;
5334 13 return 0;
5335 }
5336
4/4
✓ Branch 0 taken 2354 times.
✓ Branch 1 taken 29367 times.
✓ Branch 2 taken 2116 times.
✓ Branch 3 taken 238 times.
31721 if ( dmisc2==e2tSPLITHIT && !canmove(sclk>>8,(zfix)(4),0,true) ) { sclk=0; return 0; }
5337
5338 31483 break;
5339 }
5340 case right:
5341 {
5342
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 35722 times.
35722 if(x>=(dmisc2==e2tSPLITHIT ? 255 : 240)) //vires
5343 {
5344 sclk=0;
5345 return 0;
5346 }
5347
4/4
✓ Branch 0 taken 3288 times.
✓ Branch 1 taken 32434 times.
✓ Branch 2 taken 3018 times.
✓ Branch 3 taken 270 times.
35722 if ( dmisc2==e2tSPLITHIT && !canmove(sclk>>8,(zfix)(4),0,true) ) { sclk=0; return 0; } //vires
5348 35452 break;
5349 }
5350 }
5351
5352 91220 int32_t move = knockbackSpeed;
5353
2/2
✓ Branch 0 taken 86337 times.
✓ Branch 1 taken 91220 times.
177557 while(move>0)
5354 {
5355
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 91220 times.
91220 int32_t thismove = zc_min(8, move);
5356 91220 move -= thismove;
5357 91220 hitdir = (sclk>>8);
5358
5/5
✓ Branch 0 taken 1785 times.
✓ Branch 1 taken 10357 times.
✓ Branch 2 taken 12143 times.
✓ Branch 3 taken 31483 times.
✓ Branch 4 taken 35452 times.
91220 switch(sclk>>8)
5359 {
5360 case up:
5361 10357 y-=thismove;
5362 10357 break;
5363
5364 case down:
5365 12143 y+=thismove;
5366 12143 break;
5367
5368 case left:
5369 31483 x-=thismove;
5370 31483 break;
5371
5372 case right:
5373 35452 x+=thismove;
5374 35452 break;
5375 }
5376
2/2
✓ Branch 0 taken 86337 times.
✓ Branch 1 taken 4883 times.
91220 if(!canmove(sclk>>8,(zfix)0,0,true))
5377 {
5378
3/3
✓ Branch 0 taken 1973 times.
✓ Branch 1 taken 2906 times.
✓ Branch 2 taken 4 times.
4883 switch(sclk>>8)
5379 {
5380 case up:
5381 case down:
5382
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1973 times.
1973 if(y < 0)
5383 y = 0;
5384
2/2
✓ Branch 0 taken 325 times.
✓ Branch 1 taken 1648 times.
1973 else if((int32_t(y)&15) > 7)
5385 325 y=(int32_t(y)&0xF0)+16;
5386 else
5387 1648 y=(int32_t(y)&0xF0);
5388
5389 1973 break;
5390
5391 case left:
5392 case right:
5393
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 2902 times.
2906 if(x < 0)
5394 4 x = 0;
5395
2/2
✓ Branch 0 taken 833 times.
✓ Branch 1 taken 2069 times.
2902 else if((int32_t(x)&15) > 7)
5396 833 x=(int32_t(x)&0xF0)+16;
5397 else
5398 2069 x=(int32_t(x)&0xF0);
5399
5400 2906 break;
5401 }
5402
5403 4883 sclk=0;
5404 4883 clk3=0;
5405 4883 break;
5406 }
5407 }
5408
5409
2/2
✓ Branch 0 taken 83859 times.
✓ Branch 1 taken 7361 times.
91220 if((sclk&255)==0)
5410 {
5411 //hitdir = -1;
5412 7361 sclk=0;
5413 7361 }
5414 91220 return 2;
5415 15623459 }
5416
5417 bool enemy::can_slide()
5418 {
5419 if(sclk==0 || (hp<=0 && !immortal))
5420 return false;
5421
5422 if((sclk&255)==16 && (get_qr(qr_OLD_ENEMY_KNOCKBACK_COLLISION) || knockbackSpeed!=4 ? !canmove(sclk>>8,(zfix) (dmisc2==e2tSPLITHIT ? 1 : 12),0,true) : !canmove(sclk>>8,(zfix) (dmisc2==e2tSPLITHIT ? 1 : knockbackSpeed),0,true)))
5423 {
5424 return false;
5425 }
5426
5427 return true;
5428 }
5429
5430 bool enemy::fslide()
5431 {
5432 if(sclk==0 || (hp<=0 && !immortal))
5433 return false;
5434
5435 if((sclk&255)==16 && !canmove(sclk>>8,(zfix)12,spw_floater,true))
5436 {
5437 sclk=0;
5438 return false;
5439 }
5440
5441 --sclk;
5442
5443 switch(sclk>>8)
5444 {
5445 case up:
5446 if(y<=16)
5447 {
5448 sclk=0;
5449 return false;
5450 }
5451
5452 break;
5453
5454 case down:
5455 if(y>=160)
5456 {
5457 sclk=0;
5458 return false;
5459 }
5460
5461 break;
5462
5463 case left:
5464 if(x<=16)
5465 {
5466 sclk=0;
5467 return false;
5468 }
5469
5470 break;
5471
5472 case right:
5473 if(x>=240)
5474 {
5475 sclk=0;
5476 return false;
5477 }
5478
5479 break;
5480 }
5481 hitdir = (sclk>>8);
5482 switch(sclk>>8)
5483 {
5484 case up:
5485 y-=4;
5486 break;
5487
5488 case down:
5489 y+=4;
5490 break;
5491
5492 case left:
5493 x-=4;
5494 break;
5495
5496 case right:
5497 x+=4;
5498 break;
5499 }
5500
5501 if(!canmove(sclk>>8,(zfix)0,spw_floater,true))
5502 {
5503 switch(sclk>>8)
5504 {
5505 case up:
5506 case down:
5507 if((int32_t(y)&15) > 7)
5508 y=(int32_t(y)&0xF0)+16;
5509 else
5510 y=(int32_t(y)&0xF0);
5511
5512 break;
5513
5514 case left:
5515 case right:
5516 if((int32_t(x)&15) > 7)
5517 x=(int32_t(x)&0xF0)+16;
5518 else
5519 x=(int32_t(x)&0xF0);
5520
5521 break;
5522 }
5523
5524 sclk=0;
5525 clk3=0;
5526 }
5527
5528 if((sclk&255)==0)
5529 sclk=0;
5530
5531 return true;
5532 }
5533
5534 bool enemy::knockback(int32_t time, int32_t dir, int32_t speed)
5535 {
5536 if((hp<=0 && !immortal)) return false; //No knocking back dead/mid-knockback enemies
5537 if(!canmove(dir,(zfix)speed,0,0,0,15,15,true)) return false; //from slide(); collision check
5538 bool ret = sprite::knockback(time, dir, speed);
5539 if(ret) sclk = 0; //kill engine knockback if interrupted
5540 //! Perhaps also set hitdir here, if needed for timing? -Z
5541 return ret;
5542 }
5543
5544 37821661 bool enemy::runKnockback()
5545 {
5546
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 37821661 times.
37821661 if((script_knockback_clk&0xFF)==0)
5547 {
5548 37821661 script_knockback_clk = 0;
5549 37821661 return false;
5550 }
5551 if(knockbackflags & FLAG_NOSCRIPTKNOCKBACK)
5552 {
5553 return false;
5554 }
5555 int32_t move = script_knockback_speed;
5556 int32_t kb_dir = script_knockback_clk>>8;
5557 --script_knockback_clk;
5558
5559 while(move>0)
5560 {
5561 int32_t thismove = zc_min(get_qr(qr_OLD_SCRIPTED_KNOCKBACK)?8:4, move);
5562 move -= thismove;
5563 hitdir = kb_dir;
5564 switch(kb_dir)
5565 {
5566 case r_up:
5567 case l_up:
5568 case up:
5569 y-=thismove;
5570 break;
5571
5572 case r_down:
5573 case l_down:
5574 case down:
5575 y+=thismove;
5576 break;
5577 }
5578 switch(kb_dir)
5579 {
5580 case l_up:
5581 case l_down:
5582 case left:
5583 x-=thismove;
5584 break;
5585
5586 case r_up:
5587 case r_down:
5588 case right:
5589 x+=thismove;
5590 break;
5591 }
5592 if (get_qr(qr_OLD_SCRIPTED_KNOCKBACK))
5593 {
5594 if(!canmove(kb_dir,(zfix)0,0,true))
5595 {
5596 script_knockback_clk=0;
5597 clk3=0;
5598 //Fix to grid
5599 switch(kb_dir)
5600 {
5601 case up:
5602 case down:
5603 break;
5604 default:
5605 if(x < 0)
5606 x = 0;
5607 else if((int32_t(x)&15) > 7)
5608 x=(int32_t(x)&0xF0)+16;
5609 else
5610 x=(int32_t(x)&0xF0);
5611 break;
5612 }
5613 switch(kb_dir)
5614 {
5615 case left:
5616 case right:
5617 break;
5618 default:
5619 if(y < 0)
5620 y = 0;
5621 else if((int32_t(y)&15) > 7)
5622 y=(int32_t(y)&0xF0)+16;
5623 else
5624 y=(int32_t(y)&0xF0);
5625 break;
5626 }
5627 break;
5628 }
5629 }
5630 else
5631 {
5632 if(!scr_canplace(x,y,0,true))
5633 {
5634 script_knockback_clk=0;
5635 clk3=0;
5636 //Fix to grid
5637 if (OFFGRID_ENEMY)
5638 {
5639 switch(kb_dir)
5640 {
5641 case up:
5642 case down:
5643 break;
5644 default:
5645 if(x < 0)
5646 x = 0;
5647 else if((int32_t(x)&7) > 3)
5648 x=(int32_t(x)&0xF8)+8;
5649 else
5650 x=(int32_t(x)&0xF8);
5651 break;
5652 }
5653 switch(kb_dir)
5654 {
5655 case left:
5656 case right:
5657 break;
5658 default:
5659 if(y < 0)
5660 y = 0;
5661 else if((int32_t(y)&7) > 3)
5662 y=(int32_t(y)&0xF8)+8;
5663 else
5664 y=(int32_t(y)&0xF8);
5665 break;
5666 }
5667 }
5668 else
5669 {
5670 switch(kb_dir)
5671 {
5672 case up:
5673 case down:
5674 break;
5675 default:
5676 if(x < 0)
5677 x = 0;
5678 else if((int32_t(x)&15) > 7)
5679 x=(int32_t(x)&0xF0)+16;
5680 else
5681 x=(int32_t(x)&0xF0);
5682 break;
5683 }
5684 switch(kb_dir)
5685 {
5686 case left:
5687 case right:
5688 break;
5689 default:
5690 if(y < 0)
5691 y = 0;
5692 else if((int32_t(y)&15) > 7)
5693 y=(int32_t(y)&0xF0)+16;
5694 else
5695 y=(int32_t(y)&0xF0);
5696 break;
5697 }
5698 }
5699 break;
5700 }
5701
5702 }
5703 }
5704 return true;
5705 37821661 }
5706 // changes enemy's direction, checking restrictions
5707 // rate: 0 = no random changes, 16 = always random change
5708 // homing: 0 = none, 256 = always
5709 // grumble 0 = none, 4 = strongest appetite
5710 520316 void enemy::newdir(int32_t newrate,int32_t newhoming,int32_t special)
5711 {
5712 520316 int32_t ndir=-1;
5713
5714
4/4
✓ Branch 0 taken 109954 times.
✓ Branch 1 taken 410362 times.
✓ Branch 2 taken 37802 times.
✓ Branch 3 taken 72152 times.
520316 if(grumble != 0 && (zc_oldrand()&3)<abs(grumble)) //yes, I know checking if grumble is equal to if grumble == 0, but the latter makes the intention more clear to less experienced coders who might join.
5715 {
5716 72152 int32_t i = Lwpns.idFirst(wBait);
5717
1/2
✓ Branch 0 taken 72152 times.
✗ Branch 1 not taken.
72152 if(i >= 0) //idfirst returns -1 if it can't find any
5718 {
5719 weapon *w = (weapon*)Lwpns.spr(i);
5720 if (get_qr(qr_FIND_CLOSEST_BAIT))
5721 {
5722 int32_t currentrange;
5723 if (distance(x, y, w->x, w->y) < w->misc2 || w->misc2 == 0) currentrange = distance(x, y, w->x, w->y);
5724 else currentrange = -1;
5725 int curid = i;
5726 ++i; //increment beforehand cause we just checked the first bait weapon and all others must be after it. ...otherwise it wouldn't be the first. -Deedee
5727 for(; i<Lwpns.Count(); ++i)
5728 {
5729 weapon *lw = (weapon*)Lwpns.spr(i);
5730 if (lw->id == wBait && distance(x, y, lw->x, lw->y) < currentrange && (distance(x, y, lw->x, lw->y) < lw->misc2 || lw->misc2 == 0))
5731 {
5732 currentrange = distance(x, y, lw->x, lw->y);
5733 curid = i;
5734 }
5735 }
5736 i = curid;
5737 if (currentrange == -1) i = -1;
5738 }
5739 else
5740 {
5741 if (!(distance(x, y, w->x, w->y) < w->misc2 || w->misc2 == 0)) i = -1;
5742 }
5743 if (i >= 0)
5744 {
5745 int32_t bx = Lwpns.spr(i)->x;
5746 int32_t by = Lwpns.spr(i)->y;
5747
5748 if(abs(int32_t(y)-by)>14)
5749 {
5750 ndir = (by<y) ? up : down;
5751 if (grumble < 0 || (itemsbuf[((weapon*)Lwpns.spr(i))->parentitem].flags & item_flag1)) ndir = oppositeDir[ndir];
5752 if(canmove(ndir,special,false))
5753 {
5754 dir=ndir;
5755 return;
5756 }
5757 }
5758
5759 ndir = (bx<x) ? left : right;
5760 if (grumble < 0 || (itemsbuf[((weapon*)Lwpns.spr(i))->parentitem].flags & item_flag1)) ndir = oppositeDir[ndir];
5761 if(canmove(ndir,special,false))
5762 {
5763 dir=ndir;
5764 return;
5765 }
5766 }
5767 }
5768 72152 }
5769
5770
2/2
✓ Branch 0 taken 352448 times.
✓ Branch 1 taken 167868 times.
520316 if((zc_oldrand()&255)<abs(newhoming))
5771 {
5772 167868 ndir = lined_up(8,false);
5773
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 167868 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
167868 if (newhoming < 0 && ndir >= 0) ndir = oppositeDir[ndir];
5774
4/4
✓ Branch 0 taken 45336 times.
✓ Branch 1 taken 122532 times.
✓ Branch 2 taken 5715 times.
✓ Branch 3 taken 39621 times.
167868 if(ndir>=0 && canmove(ndir,special,false))
5775 {
5776 39621 dir=ndir;
5777 39621 return;
5778 }
5779 128247 }
5780
5781 480695 int32_t i=0;
5782
5783
2/2
✓ Branch 0 taken 3335 times.
✓ Branch 1 taken 1179456 times.
1182791 for(; i<32; i++)
5784 {
5785 1179456 int32_t r=zc_oldrand();
5786
5787
2/2
✓ Branch 0 taken 344661 times.
✓ Branch 1 taken 834795 times.
1179456 if((r&15)<newrate)
5788 344661 ndir=(r>>4)&3;
5789 else
5790 834795 ndir=dir;
5791
5792
2/2
✓ Branch 0 taken 702096 times.
✓ Branch 1 taken 477360 times.
1179456 if(canmove(ndir,special,false))
5793 477360 break;
5794 702096 }
5795
5796
2/2
✓ Branch 0 taken 477360 times.
✓ Branch 1 taken 3335 times.
481448 if(i==32)
5797 {
5798
2/2
✓ Branch 0 taken 8919 times.
✓ Branch 1 taken 753 times.
9672 for(ndir=0; ndir<4; ndir++)
5799 {
5800
2/2
✓ Branch 0 taken 6337 times.
✓ Branch 1 taken 2582 times.
8919 if(canmove(ndir,special,false))
5801 2582 goto ok;
5802 6337 }
5803
5804
2/2
✓ Branch 0 taken 60 times.
✓ Branch 1 taken 693 times.
753 ndir = (isSideViewGravity()) ? (zc_oldrand()&1 ? left : right) : -1; // Sideview enemies get trapped if their dir becomes -1
5805 //...Isn't that the point? I'm not sure I understand. Certainly beats phasing through walls... -Dimi
5806 753 }
5807
5808 ok:
5809 480695 dir = ndir;
5810 520316 }
5811
5812 2632 void enemy::newdir()
5813 {
5814 2632 newdir(4,0,spw_none);
5815 2632 }
5816
5817 zfix enemy::distance_left()
5818 {
5819 int32_t a2=x.getInt();
5820 int32_t b2=y.getInt();
5821
5822 switch(dir)
5823 {
5824 case up:
5825 return (zfix)(b2&0xF);
5826
5827 case down:
5828 return (zfix)(16-(b2&0xF));
5829
5830 case left:
5831 return (zfix)(a2&0xF);
5832
5833 case right:
5834 return (zfix)(16-(a2&0xF));
5835 }
5836
5837 return (zfix)0;
5838 }
5839
5840 // keeps walking around
5841 391434 void enemy::constant_walk(int32_t newrate,int32_t newhoming,int32_t special)
5842 {
5843
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 391434 times.
391434 if(slide())
5844 return;
5845
5846
8/12
✓ Branch 0 taken 387600 times.
✓ Branch 1 taken 3834 times.
✓ Branch 2 taken 387600 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 383173 times.
✓ Branch 5 taken 4427 times.
✓ Branch 6 taken 383173 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 383173 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 383173 times.
391434 if(clk<0 || dying || stunclk || watch || ceiling || frozenclock )
5847 8261 return;
5848
5849
2/2
✓ Branch 0 taken 26115 times.
✓ Branch 1 taken 357058 times.
383173 if(clk3<=0)
5850 {
5851 26115 fix_coords(true);
5852 26115 newdir(newrate,newhoming,special);
5853
5854
1/2
✓ Branch 0 taken 26115 times.
✗ Branch 1 not taken.
26115 if(step==0)
5855 clk3=0;
5856 else
5857 26115 clk3=int32_t(16.0/step);
5858 26115 }
5859
2/2
✓ Branch 0 taken 357013 times.
✓ Branch 1 taken 45 times.
357058 else if(scored)
5860 {
5861 45 dir^=1;
5862
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 45 times.
45 if (step != 0) clk3=int32_t(16.0/step)-clk3;
5863 else clk3=32767;
5864 45 }
5865
5866
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 383173 times.
383173 if (step != 0) --clk3;
5867 383173 move(step);
5868 391434 }
5869
5870 void enemy::constant_walk()
5871 {
5872 constant_walk(4,0,spw_none);
5873 }
5874
5875 35220 int32_t enemy::pos(int32_t newx,int32_t newy)
5876 {
5877 35220 return (newy<<8)+newx;
5878 }
5879
5880 // for variable step rates
5881 473814 void enemy::variable_walk(int32_t newrate,int32_t newhoming,int32_t special)
5882 {
5883
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 473814 times.
473814 if(slide())
5884 return;
5885
5886
10/14
✓ Branch 0 taken 473814 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 473814 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 465189 times.
✓ Branch 5 taken 8625 times.
✓ Branch 6 taken 455915 times.
✓ Branch 7 taken 9274 times.
✓ Branch 8 taken 418370 times.
✓ Branch 9 taken 37545 times.
✓ Branch 10 taken 418370 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 418370 times.
✗ Branch 13 not taken.
473814 if(clk<0 || dying || stunclk || watch || step == 0 || ceiling || frozenclock )
5887 55444 return;
5888
5889 418370 zfix dx = (zfix)0;
5890 418370 zfix dy = (zfix)0;
5891
5892
5/9
✓ Branch 0 taken 93441 times.
✓ Branch 1 taken 97752 times.
✓ Branch 2 taken 111603 times.
✓ Branch 3 taken 113743 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✓ Branch 8 taken 1831 times.
418370 switch(dir)
5893 {
5894 case 8:
5895 case up:
5896 93441 dy-=step;
5897 93441 break;
5898
5899 case 12:
5900 case down:
5901 97752 dy+=step;
5902 97752 break;
5903
5904 case 14:
5905 case left:
5906 111603 dx-=step;
5907 111603 break;
5908
5909 case 10:
5910 case right:
5911 113743 dx+=step;
5912 113743 break;
5913
5914 case 15:
5915 case l_up:
5916 dx-=step;
5917 dy-=step;
5918 break;
5919
5920 case 9:
5921 case r_up:
5922 dx+=step;
5923 dy-=step;
5924 break;
5925
5926 case 13:
5927 case l_down:
5928 dx-=step;
5929 dy+=step;
5930 break;
5931
5932 case 11:
5933 case r_down:
5934 dx+=step;
5935 dy+=step;
5936 break;
5937 }
5938
5939
8/8
✓ Branch 0 taken 204198 times.
✓ Branch 1 taken 214172 times.
✓ Branch 2 taken 22777 times.
✓ Branch 3 taken 181421 times.
✓ Branch 4 taken 11556 times.
✓ Branch 5 taken 11221 times.
✓ Branch 6 taken 405927 times.
✓ Branch 7 taken 12443 times.
418370 if(((int32_t(x)&15)==0 && (int32_t(y)&15)==0 && clk3!=pos(x,y)) ||
5940 406814 m_walkflag(int32_t(x+dx),int32_t(y+dy), spw_halfstep, dir))
5941 {
5942 12443 fix_coords();
5943 12443 newdir(newrate,newhoming,special);
5944 12443 clk3=pos(x,y);
5945 12443 }
5946
5947 418370 move(step);
5948 473814 }
5949
5950 // pauses for a while after it makes a complete move (to a new square)
5951 12314680 void enemy::halting_walk(int32_t newrate,int32_t newhoming,int32_t special,int32_t newhrate, int32_t haltcnt)
5952 {
5953
4/4
✓ Branch 0 taken 79858 times.
✓ Branch 1 taken 12234822 times.
✓ Branch 2 taken 67026 times.
✓ Branch 3 taken 12832 times.
12314680 if(sclk && clk2)
5954 {
5955 12832 clk3=0;
5956 12832 }
5957
5958
11/14
✓ Branch 0 taken 12241688 times.
✓ Branch 1 taken 72992 times.
✓ Branch 2 taken 12241688 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 12241688 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 11774520 times.
✓ Branch 7 taken 467168 times.
✓ Branch 8 taken 11636771 times.
✓ Branch 9 taken 137749 times.
✓ Branch 10 taken 11633563 times.
✓ Branch 11 taken 3208 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 11633563 times.
12314680 if(slide() || clk<0 || dying || stunclk || watch || ceiling || frozenclock)
5959 {
5960 681117 return;
5961 }
5962
5963
2/2
✓ Branch 0 taken 2132459 times.
✓ Branch 1 taken 9501104 times.
11633563 if(clk2>0)
5964 {
5965 2132459 --clk2;
5966 2132459 return;
5967 }
5968
5969
2/2
✓ Branch 0 taken 410610 times.
✓ Branch 1 taken 9090494 times.
9501104 if(clk3<=0)
5970 {
5971 410610 fix_coords(true);
5972 410610 newdir(newrate,newhoming,special);
5973 410610 clk3=int32_t(16.0/step);
5974
2/2
✓ Branch 0 taken 410415 times.
✓ Branch 1 taken 195 times.
410610 if (step == 0) clk3 = 32767; //It used to return this in 2.53 and I'm unsure why; I'm guessing dividing by 0 gave max int? Either way, can't be 0 here or scripts break.
5975
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 410610 times.
410610 if(clk2<0)
5976 {
5977 clk2=0;
5978 }
5979
2/2
✓ Branch 0 taken 54758 times.
✓ Branch 1 taken 355852 times.
410610 else if((zc_oldrand()&15)<newhrate)
5980 {
5981 54758 clk2=haltcnt;
5982 54758 return;
5983 }
5984 355852 }
5985
2/2
✓ Branch 0 taken 9087335 times.
✓ Branch 1 taken 3159 times.
9090494 else if(scored)
5986 {
5987 3159 dir^=1;
5988
5989
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 3154 times.
3159 if (step != 0) clk3=int32_t(16.0/step)-clk3;
5990 5 else clk3=32767;
5991 3159 }
5992
5993
2/2
✓ Branch 0 taken 74649 times.
✓ Branch 1 taken 9371697 times.
9446346 if (step != 0) --clk3;
5994 9446346 move(step);
5995 12314680 }
5996
5997 // 8-directional movement, aligns to 8 pixels
5998 void enemy::constant_walk_8(int32_t newrate,int32_t newhoming,int32_t special)
5999 {
6000 if(clk<0 || dying || stunclk || watch || ceiling || frozenclock)
6001 return;
6002
6003 if(clk3<=0)
6004 {
6005 newdir_8(newrate,newhoming,special);
6006 clk3=int32_t(8.0/step);
6007 if (step == 0) clk3 = 32767;
6008 }
6009
6010 if (step != 0) --clk3;
6011 move(step);
6012 }
6013 // 8-directional movement, aligns to 8 pixels
6014 242393 void enemy::constant_walk_8_old(int32_t newrate,int32_t newhoming,int32_t special)
6015 {
6016
6/12
✓ Branch 0 taken 242393 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 242393 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 242393 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 242393 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 242393 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 242393 times.
242393 if(clk<0 || dying || stunclk || watch || ceiling || frozenclock)
6017 return;
6018
6019
2/2
✓ Branch 0 taken 226158 times.
✓ Branch 1 taken 16235 times.
242393 if(clk3<=0)
6020 {
6021 16235 newdir_8(newrate,newhoming,special);
6022 16235 clk3=int32_t(8.0/step);
6023
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16235 times.
16235 if (step == 0) clk3 = 32767;
6024 16235 }
6025
6026
1/2
✓ Branch 0 taken 242393 times.
✗ Branch 1 not taken.
242393 if (step != 0) --clk3;
6027 242393 move(step);
6028 242393 }
6029
6030 void enemy::halting_walk_8(int32_t newrate,int32_t newhoming, int32_t newclk,int32_t special,int32_t newhrate, int32_t haltcnt)
6031 {
6032 if(clk<0 || dying || stunclk || watch || frozenclock)
6033 return;
6034
6035 if(!canmove(dir,step,special,false))
6036 clk3=0;
6037
6038 if(clk2>0)
6039 {
6040 --clk2;
6041 return;
6042 }
6043
6044 if(clk3<=0)
6045 {
6046 newdir_8(newrate,newhoming,special);
6047 clk3=newclk;
6048
6049 if(clk2<0)
6050 {
6051 clk2=0;
6052 }
6053 else if((zc_oldrand()&15)<newhrate)
6054 {
6055 newdir_8(newrate,newhoming,special);
6056 clk2=haltcnt;
6057 return;
6058 }
6059 }
6060
6061 --clk3;
6062 move(step);
6063 }
6064
6065 // 8-directional movement, no alignment
6066 4691075 void enemy::variable_walk_8(int32_t newrate,int32_t newhoming, int32_t newclk,int32_t special)
6067 {
6068
9/12
✓ Branch 0 taken 4483752 times.
✓ Branch 1 taken 207323 times.
✓ Branch 2 taken 4483752 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4457131 times.
✓ Branch 5 taken 26621 times.
✓ Branch 6 taken 4446084 times.
✓ Branch 7 taken 11047 times.
✓ Branch 8 taken 4446084 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 4446084 times.
4691075 if(clk<0 || dying || stunclk || watch || ceiling || frozenclock)
6069 244991 return;
6070
6071
2/2
✓ Branch 0 taken 4415704 times.
✓ Branch 1 taken 30380 times.
4446084 if(!canmove(dir,step,special,false))
6072 30380 clk3=0;
6073
6074
2/2
✓ Branch 0 taken 3891681 times.
✓ Branch 1 taken 554403 times.
4446084 if(clk3<=0)
6075 {
6076 554403 newdir_8(newrate,newhoming,special);
6077 554403 clk3=newclk;
6078 554403 }
6079
6080 4446084 --clk3;
6081 4446084 move(step);
6082 4691075 }
6083
6084 // same as above but with variable enemy size
6085 94563 void enemy::variable_walk_8(int32_t newrate,int32_t newhoming, int32_t newclk,int32_t special,int32_t dx1,int32_t dy1,int32_t dx2,int32_t dy2)
6086 {
6087
8/12
✓ Branch 0 taken 93367 times.
✓ Branch 1 taken 1196 times.
✓ Branch 2 taken 93367 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 93367 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 93316 times.
✓ Branch 7 taken 51 times.
✓ Branch 8 taken 93316 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 93316 times.
94563 if(clk<0 || dying || stunclk || watch || ceiling || frozenclock)
6088 1247 return;
6089
6090
2/2
✓ Branch 0 taken 91982 times.
✓ Branch 1 taken 1334 times.
93316 if(!canmove(dir,step,special,dx1,dy1,dx2,dy2,false))
6091 1334 clk3=0;
6092
6093
2/2
✓ Branch 0 taken 86841 times.
✓ Branch 1 taken 6475 times.
93316 if(clk3<=0)
6094 {
6095 6475 newdir_8(newrate,newhoming,special,dx1,dy1,dx2,dy2);
6096 6475 clk3=newclk;
6097 6475 }
6098
6099 93316 --clk3;
6100 93316 move(step);
6101 94563 }
6102
6103 // the variable speed floater movement
6104 // ms is max speed
6105 // ss is step speed
6106 // s is step count
6107 // p is pause count
6108 // g is graduality :)
6109 //floater_walk(rate,hrate,dstep/100,(zfix)0,10,dmisc16,dmisc17);
6110 3989892 void enemy::floater_walk(int32_t newrate,int32_t newclk,zfix ms,zfix ss,int32_t s,int32_t p, int32_t g)
6111 {
6112 3989892 ++clk2;
6113 3989892 byte over_pit = overpit(this);
6114
6115
4/4
✓ Branch 0 taken 1114794 times.
✓ Branch 1 taken 2875098 times.
✓ Branch 2 taken 1114527 times.
✓ Branch 3 taken 267 times.
3989892 if(dmisc1 && over_pit) p = 0;
6116
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 56213 times.
✓ Branch 2 taken 1570783 times.
✓ Branch 3 taken 2230728 times.
✓ Branch 4 taken 132168 times.
3989892 switch(movestatus)
6117 {
6118 //! This needs a case 4 (landing)....if we want to halt, we move to case 4, and
6119 //! if the conditions prevent it, we jump back to case 2.
6120 case 0: // paused
6121
2/2
✓ Branch 0 taken 54765 times.
✓ Branch 1 taken 1448 times.
56213 if(clk2>=p)
6122 {
6123 1448 movestatus=1;
6124 1448 clk2=0;
6125 1448 }
6126
6127 56213 break;
6128
6129 case 1: // speeding up
6130
1/2
✓ Branch 0 taken 1570783 times.
✗ Branch 1 not taken.
1570783 if (s >= 0)
6131 {
6132
2/2
✓ Branch 0 taken 1559550 times.
✓ Branch 1 taken 11233 times.
1570783 if(clk2<g*s)
6133 {
6134
2/2
✓ Branch 0 taken 1458948 times.
✓ Branch 1 taken 100602 times.
1559550 if(!((clk2-1)%g))
6135 100602 step+=ss;
6136 1559550 }
6137 else
6138 {
6139 11233 movestatus=2;
6140 11233 clk2=0;
6141 }
6142 1570783 }
6143 else
6144 {
6145 if(step < ms)
6146 {
6147 if(!((clk2-1)%g))
6148 {
6149 step+=ss;
6150 if (step >= ms) step = ms;
6151 }
6152 }
6153 else
6154 {
6155 step = ms;
6156 movestatus=2;
6157 clk2=0;
6158 }
6159 }
6160
6161 1570783 break;
6162
6163 case 2: // normal
6164 2230728 step=ms;
6165
6166
6/8
✗ Branch 0 not taken.
✓ Branch 1 taken 2230728 times.
✓ Branch 2 taken 477682 times.
✓ Branch 3 taken 1753046 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1753046 times.
✓ Branch 6 taken 1750807 times.
✓ Branch 7 taken 2239 times.
2230728 if(clk2>(dmisc15>0?dmisc15:48) && !(zc_oldrand()%(dmisc14>0?dmisc14:768)))
6167 {
6168
1/2
✓ Branch 0 taken 2239 times.
✗ Branch 1 not taken.
2239 if (s >= 0) step=ss*s;
6169 else step=ms;
6170 2239 movestatus=3;
6171 2239 clk2=0;
6172 2239 }
6173
6174 2230728 break;
6175
6176 case 3: // slowing down
6177
1/2
✓ Branch 0 taken 132168 times.
✗ Branch 1 not taken.
132168 if (s >= 0)
6178 {
6179
2/2
✓ Branch 0 taken 130491 times.
✓ Branch 1 taken 1677 times.
132168 if(clk2<=g*s)
6180 {
6181 { //don't slow down over pits
6182
6183
2/2
✓ Branch 0 taken 267 times.
✓ Branch 1 taken 130224 times.
130491 if(over_pit)
6184 {
6185
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 267 times.
267 if(dmisc1)
6186 {
6187 step=ms;
6188 }
6189 267 }
6190 else //can slow down
6191 {
6192
4/4
✓ Branch 0 taken 8036 times.
✓ Branch 1 taken 122188 times.
✓ Branch 2 taken 7668 times.
✓ Branch 3 taken 368 times.
130224 if(!(clk2%g) && !dmisc1)
6193 7668 step-=ss;
6194 }
6195 }
6196
6197
6198 130491 }
6199 else
6200 {
6201 //if((moveflags&move_can_pitfall)) //don't check pits if the enemy ignores them
6202 //this doesn't help keese, as they have a z of 0.
6203 //they always nee to run this check.
6204 {
6205
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1677 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1677 if(over_pit &&!dmisc1)
6206 {
6207 --clk2; //if over a pit, don't land, and revert clock change
6208 }
6209 else //can land safely
6210 {
6211 1677 movestatus=0;
6212
3/4
✓ Branch 0 taken 1115 times.
✓ Branch 1 taken 562 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1115 times.
1677 if(dmisc1&&!over_pit)
6213 1115 step=0;
6214 1677 clk2=0;
6215 }
6216 }
6217
6218 }
6219 132168 }
6220 else
6221 {
6222 if(step > 0)
6223 {
6224 if(over_pit)
6225 {
6226 if(dmisc1)
6227 {
6228 step=ms;
6229 }
6230 }
6231 else //can slow down
6232 {
6233 if(!(clk2%g))
6234 step-=ss;
6235 }
6236 }
6237 else
6238 {
6239 //if((moveflags&move_can_pitfall)) //don't check pits if the enemy ignores them
6240 //this doesn't help keese, as they have a z of 0.
6241 //they always nee to run this check.
6242 if(over_pit)
6243 {
6244 step+=ss; //if over a pit, don't land, and revert clock change
6245 }
6246 else //can land safely
6247 {
6248 movestatus=0;
6249 step=0;
6250 clk2=0;
6251 }
6252 }
6253 }
6254
6255 132168 break;
6256 }
6257
6258
2/2
✓ Branch 0 taken 2239722 times.
✓ Branch 1 taken 1750170 times.
3989892 variable_walk_8(movestatus==2?newrate:0,homing,newclk,spw_floater);
6259 3989892 }
6260
6261 void enemy::floater_walk(int32_t newrate,int32_t newclk,zfix s)
6262 {
6263 floater_walk(newrate,newclk,s,(zfix)0.125,3,80,32);
6264 }
6265
6266 // Checks if enemy is lined up with Hero. If so, returns direction Hero is
6267 // at as compared to enemy. Returns -1 if not lined up. Range is inclusive.
6268 923644 int32_t enemy::lined_up(int32_t range, bool dir8)
6269 {
6270 923644 int32_t lx = Hero.getX();
6271 923644 int32_t ly = Hero.getY();
6272
6273
2/2
✓ Branch 0 taken 38484 times.
✓ Branch 1 taken 885160 times.
923644 if(abs(lx-int32_t(x))<=range)
6274 {
6275
2/2
✓ Branch 0 taken 16113 times.
✓ Branch 1 taken 22371 times.
38484 if(ly<y)
6276 {
6277 16113 return up;
6278 }
6279
6280 22371 return down;
6281 }
6282
6283
2/2
✓ Branch 0 taken 56299 times.
✓ Branch 1 taken 828861 times.
885160 if(abs(ly-int32_t(y))<=range)
6284 {
6285
2/2
✓ Branch 0 taken 30278 times.
✓ Branch 1 taken 26021 times.
56299 if(lx<x)
6286 {
6287 30278 return left;
6288 }
6289
6290 26021 return right;
6291 }
6292
6293
2/2
✓ Branch 0 taken 159811 times.
✓ Branch 1 taken 669050 times.
828861 if(dir8)
6294 {
6295
2/2
✓ Branch 0 taken 252160 times.
✓ Branch 1 taken 416890 times.
669050 if(abs(lx-x)-abs(ly-y)<=range)
6296 //if(abs(lx-x)-abs(ly-y)<=range && abs(ly-y)-abs(lx-x)<=range) //Fix floating enemies not seeking hero. -Tamamo
6297 {
6298
2/2
✓ Branch 0 taken 105160 times.
✓ Branch 1 taken 147000 times.
252160 if(ly<y)
6299 {
6300
2/2
✓ Branch 0 taken 56622 times.
✓ Branch 1 taken 48538 times.
105160 if(lx<x)
6301 {
6302 56622 return l_up;
6303 }
6304 else
6305 {
6306 48538 return r_up;
6307 }
6308 }
6309 else
6310 {
6311
2/2
✓ Branch 0 taken 76220 times.
✓ Branch 1 taken 70780 times.
147000 if(lx<x)
6312 {
6313 70780 return l_down;
6314 }
6315 else
6316 {
6317 76220 return r_down;
6318 }
6319 }
6320 }
6321 416890 }
6322
6323 576701 return -1;
6324 923644 }
6325
6326 // returns true if Hero is within 'range' pixels of the enemy
6327 27884 bool enemy::HeroInRange(int32_t range)
6328 {
6329 27884 int32_t lx = Hero.getX();
6330 27884 int32_t ly = Hero.getY();
6331
2/2
✓ Branch 0 taken 22775 times.
✓ Branch 1 taken 5109 times.
27884 return abs(lx-int32_t(x))<=range && abs(ly-int32_t(y))<=range;
6332 }
6333
6334 // place the enemy in line with Hero (red wizzrobes)
6335 4858 void enemy::place_on_axis(bool floater, bool solid_ok)
6336 {
6337
6/6
✓ Branch 0 taken 573 times.
✓ Branch 1 taken 4285 times.
✓ Branch 2 taken 4316 times.
✓ Branch 3 taken 542 times.
✓ Branch 4 taken 573 times.
✓ Branch 5 taken 3743 times.
4858 int32_t lx=zc_min(zc_max(int32_t(Hero.getX())&0xF0,32),208);
6338
6/6
✓ Branch 0 taken 437 times.
✓ Branch 1 taken 4421 times.
✓ Branch 2 taken 4082 times.
✓ Branch 3 taken 776 times.
✓ Branch 4 taken 437 times.
✓ Branch 5 taken 3645 times.
4858 int32_t ly=zc_min(zc_max(int32_t(Hero.getY())&0xF0,32),128);
6339 4858 int32_t pos2=zc_oldrand()%23;
6340 4858 int32_t tried=0;
6341 4858 bool last_resort,placed=false;
6342
6343
6344 4858 do
6345 {
6346
2/2
✓ Branch 0 taken 4432 times.
✓ Branch 1 taken 3104 times.
7536 if(pos2<14)
6347 {
6348 4432 x=(pos2<<4)+16;
6349 4432 y=ly;
6350 4432 }
6351 else
6352 {
6353 3104 x=lx;
6354 3104 y=((pos2-14)<<4)+16;
6355 }
6356
6357 // Don't commit to a last resort if position is out of bounds.
6358
6/6
✓ Branch 0 taken 7199 times.
✓ Branch 1 taken 337 times.
✓ Branch 2 taken 6889 times.
✓ Branch 3 taken 310 times.
✓ Branch 4 taken 255 times.
✓ Branch 5 taken 6634 times.
7536 last_resort= !(x<32 || y<32 || x>=224 || y>=144);
6359
6360
4/4
✓ Branch 0 taken 3879 times.
✓ Branch 1 taken 3657 times.
✓ Branch 2 taken 4912 times.
✓ Branch 3 taken 1443 times.
7536 if(abs(lx-int32_t(x))>16 || abs(ly-int32_t(y))>16)
6361 {
6362 // Red Wizzrobes should be able to appear on water, but not other
6363 // solid combos; however, they could appear on solid combos in 2.10,
6364 // and some quests depend on that.
6365
4/4
✓ Branch 0 taken 2341 times.
✓ Branch 1 taken 6228 times.
✓ Branch 2 taken 1370 times.
✓ Branch 3 taken 4858 times.
8569 if((solid_ok || !m_walkflag(x,y,floater ? spw_water : spw_door, dir))
6366 8569 && !flyerblocked(x,y,floater ? spw_floater : spw_door))
6367 4858 placed=true;
6368 8569 }
6369
6370
3/6
✓ Branch 0 taken 2678 times.
✓ Branch 1 taken 4662 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2678 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
7340 if(!placed && tried>=22 && last_resort)
6371 {
6372 placed=true;
6373 }
6374
6375 7340 ++tried;
6376 7340 pos2=(pos2+3)%23;
6377
2/2
✓ Branch 0 taken 2678 times.
✓ Branch 1 taken 4662 times.
7340 }
6378 7340 while(!placed);
6379
6380
2/2
✓ Branch 0 taken 2872 times.
✓ Branch 1 taken 1790 times.
4662 if(y==ly)
6381 2872 dir=(x<lx)?right:left;
6382 else
6383 1790 dir=(y<ly)?down:up;
6384
6385 4662 clk2=tried;
6386 4662 }
6387
6388 20213685 int32_t enemy::n_frame_n_dir(int32_t frames, int32_t ndir, int32_t f4)
6389 {
6390 20213685 int32_t t = o_tile;
6391 20213685 int32_t b = o_tile;
6392
6393 // Darknuts, but also Wizzrobes and Wallmasters
6394
3/4
✓ Branch 0 taken 8353120 times.
✓ Branch 1 taken 10837883 times.
✓ Branch 2 taken 1022682 times.
✗ Branch 3 not taken.
20213685 switch(family)
6395 {
6396 case eeWALK:
6397
5/6
✓ Branch 0 taken 505407 times.
✓ Branch 1 taken 10332476 times.
✓ Branch 2 taken 367468 times.
✓ Branch 3 taken 137939 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 367468 times.
10837883 if(dmisc9==e9tPOLSVOICE && clk2>=0 && do_animation)
6398 {
6399 367468 tile=s_tile;
6400 367468 t=s_tile;
6401 367468 b=s_tile;
6402 367468 }
6403
6404 10837883 break;
6405
6406 case eeTRAP:
6407
4/6
✓ Branch 0 taken 193566 times.
✓ Branch 1 taken 829116 times.
✓ Branch 2 taken 193566 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 193566 times.
1022682 if(dummy_int[1] && guysbuf[id].flags & guy_trp2 && do_animation) // Just to make sure
6408 {
6409 193566 tile=s_tile;
6410 193566 t=s_tile;
6411 193566 b=s_tile;
6412 193566 }
6413
6414 1022682 break;
6415
6416 case eeSPINTILE:
6417 if(misc>=96 && do_animation)
6418 {
6419 tile=o_tile+frames*ndir;
6420 t=tile;
6421 }
6422
6423 break;
6424 }
6425
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 20213685 times.
20213685 if ( do_animation )
6426 {
6427
4/6
✓ Branch 0 taken 197042 times.
✓ Branch 1 taken 20016643 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 267131 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 19749512 times.
20213685 if(ndir!=0) switch(frames)
6428 {
6429 case 2:
6430 267131 tiledir_small(dir,ndir==4);
6431 267131 break;
6432
6433 case 3:
6434 tiledir_three(dir);
6435 break;
6436
6437 case 4:
6438 19749512 tiledir(dir,ndir==4);
6439 19749512 break;
6440 20016643 }
6441
6442
2/2
✓ Branch 0 taken 10837883 times.
✓ Branch 1 taken 9375802 times.
20213685 if(family==eeWALK)
6443
6/6
✓ Branch 0 taken 10776874 times.
✓ Branch 1 taken 61009 times.
✓ Branch 2 taken 8177902 times.
✓ Branch 3 taken 2659981 times.
✓ Branch 4 taken 2644258 times.
✓ Branch 5 taken 15723 times.
10837883 tile=zc_min(tile+f4, t+frames*(zc_max(dir, 0)+1)-1);
6444 else
6445 9375802 tile+=f4;
6446 20213685 }
6447 20213685 return b;
6448 }
6449
6450 void enemy::tiledir_three(int32_t ndir)
6451 {
6452 if ( !do_animation ) return;
6453 flip=0;
6454
6455 switch(ndir)
6456 {
6457 case right:
6458 tile+=3;
6459 [[fallthrough]];
6460
6461 case left:
6462 tile+=3;
6463 [[fallthrough]];
6464
6465 case down:
6466 tile+=3;
6467 [[fallthrough]];
6468
6469 case up:
6470 break;
6471 }
6472 }
6473
6474 267131 void enemy::tiledir_small(int32_t ndir, bool fourdir)
6475 {
6476
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 267131 times.
267131 if ( !do_animation ) return;
6477 267131 flip=0;
6478
6479
8/9
✓ Branch 0 taken 53829 times.
✓ Branch 1 taken 54679 times.
✓ Branch 2 taken 67727 times.
✓ Branch 3 taken 71182 times.
✓ Branch 4 taken 5706 times.
✓ Branch 5 taken 5154 times.
✓ Branch 6 taken 4872 times.
✓ Branch 7 taken 3982 times.
✗ Branch 8 not taken.
267131 switch(ndir)
6480 {
6481 case 8:
6482 case up:
6483 53829 break;
6484
6485 case 12:
6486 case down:
6487 54679 tile+=2;
6488 54679 break;
6489
6490 case 14:
6491 case left:
6492 67727 tile+=4;
6493 67727 break;
6494
6495 case 10:
6496 case right:
6497 71182 tile+=6;
6498 71182 break;
6499
6500 case 9:
6501 case r_up:
6502
1/2
✓ Branch 0 taken 5706 times.
✗ Branch 1 not taken.
5706 if(fourdir)
6503 5706 break;
6504
6505 tile+=10;
6506 break;
6507
6508 case 11:
6509 case r_down:
6510
1/2
✓ Branch 0 taken 5154 times.
✗ Branch 1 not taken.
5154 if(fourdir)
6511 5154 tile+=2;
6512 else
6513 tile+=14;
6514
6515 5154 break;
6516
6517 case 13:
6518 case l_down:
6519
1/2
✓ Branch 0 taken 4872 times.
✗ Branch 1 not taken.
4872 if(fourdir)
6520 4872 tile+=2;
6521 else
6522 tile+=12;
6523
6524 4872 break;
6525
6526 case 15:
6527 case l_up:
6528
1/2
✓ Branch 0 taken 3982 times.
✗ Branch 1 not taken.
3982 if(fourdir)
6529 3982 break;
6530
6531 tile+=8;
6532 break;
6533
6534 default:
6535 //dir=(zc_oldrand()*100)%8;
6536 //tiledir_small(dir);
6537 // flip=zc_oldrand()&3;
6538 // tile=(zc_oldrand()*100000)%NEWMAXTILES;
6539 break;
6540 }
6541 267131 }
6542
6543 23069632 void enemy::tiledir(int32_t ndir, bool fourdir)
6544 {
6545
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 23069632 times.
23069632 if ( !do_animation ) return;
6546 23069632 flip=0;
6547
6548
9/9
✓ Branch 0 taken 4483892 times.
✓ Branch 1 taken 4141765 times.
✓ Branch 2 taken 5412757 times.
✓ Branch 3 taken 5175571 times.
✓ Branch 4 taken 825768 times.
✓ Branch 5 taken 1018734 times.
✓ Branch 6 taken 1099241 times.
✓ Branch 7 taken 845055 times.
✓ Branch 8 taken 66849 times.
23069632 switch(ndir)
6549 {
6550 case 8:
6551 case up:
6552 4483892 break;
6553
6554 case 12:
6555 case down:
6556 4141765 tile+=4;
6557 4141765 break;
6558
6559 case 14:
6560 case left:
6561 5412757 tile+=8;
6562 5412757 break;
6563
6564 case 10:
6565 case right:
6566 5175571 tile+=12;
6567 5175571 break;
6568
6569 case 9:
6570 case r_up:
6571
2/2
✓ Branch 0 taken 88653 times.
✓ Branch 1 taken 737115 times.
825768 if(fourdir)
6572 88653 break;
6573 else
6574 737115 tile+=24;
6575
6576 737115 break;
6577
6578 case 11:
6579 case r_down:
6580
2/2
✓ Branch 0 taken 101949 times.
✓ Branch 1 taken 916785 times.
1018734 if(fourdir)
6581 101949 tile+=4;
6582 else
6583 916785 tile+=32;
6584
6585 1018734 break;
6586
6587 case 13:
6588 case l_down:
6589
2/2
✓ Branch 0 taken 105945 times.
✓ Branch 1 taken 993296 times.
1099241 if(fourdir)
6590 105945 tile+=4;
6591 else
6592 993296 tile+=28;
6593
6594 1099241 break;
6595
6596 case 15:
6597 case l_up:
6598
2/2
✓ Branch 0 taken 82760 times.
✓ Branch 1 taken 762295 times.
845055 if(fourdir)
6599 82760 break;
6600 else
6601 762295 tile+=20;
6602
6603 762295 break;
6604
6605 default:
6606 //dir=(zc_oldrand()*100)%8;
6607 //tiledir(dir);
6608 // flip=zc_oldrand()&3;
6609 // tile=(zc_oldrand()*100000)%NEWMAXTILES;
6610 66849 break;
6611 }
6612 23069632 }
6613
6614 3868 void enemy::tiledir_big(int32_t ndir, bool fourdir)
6615 {
6616
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3868 times.
3868 if ( !do_animation ) return;
6617 3868 flip=0;
6618
6619
7/9
✓ Branch 0 taken 297 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 195 times.
✓ Branch 3 taken 179 times.
✓ Branch 4 taken 306 times.
✓ Branch 5 taken 1235 times.
✓ Branch 6 taken 1324 times.
✓ Branch 7 taken 332 times.
✗ Branch 8 not taken.
3868 switch(ndir)
6620 {
6621 case 8:
6622 case up:
6623 297 break;
6624
6625 case 12:
6626 case down:
6627 tile+=8;
6628 break;
6629
6630 case 14:
6631 case left:
6632 195 tile+=40;
6633 195 break;
6634
6635 case 10:
6636 case right:
6637 179 tile+=48;
6638 179 break;
6639
6640 case 9:
6641 case r_up:
6642
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 306 times.
306 if(fourdir)
6643 break;
6644
6645 306 tile+=88;
6646 306 break;
6647
6648 case 11:
6649 case r_down:
6650
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1235 times.
1235 if(fourdir)
6651 tile+=8;
6652 else
6653 1235 tile+=128;
6654
6655 1235 break;
6656
6657 case 13:
6658 case l_down:
6659
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1324 times.
1324 if(fourdir)
6660 tile+=8;
6661 else
6662 1324 tile+=120;
6663
6664 1324 break;
6665
6666 case 15:
6667 case l_up:
6668
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 332 times.
332 if(fourdir)
6669 break;
6670
6671 332 tile+=80;
6672 332 break;
6673
6674 default:
6675 //dir=(zc_oldrand()*100)%8;
6676 //tiledir_big(dir);
6677 // flip=zc_oldrand()&3;
6678 // tile=(zc_oldrand()*100000)%NEWMAXTILES;
6679 break;
6680 }
6681 3868 }
6682
6683 39891825 void enemy::update_enemy_frame()
6684 {
6685
4/4
✓ Branch 0 taken 39889519 times.
✓ Branch 1 taken 2306 times.
✓ Branch 2 taken 7 times.
✓ Branch 3 taken 39889512 times.
39891825 if(fallclk||drownclk) return;
6686
1/2
✓ Branch 0 taken 39889512 times.
✗ Branch 1 not taken.
39889512 if (!do_animation)
6687 return;
6688
6689
4/4
✓ Branch 0 taken 1474046 times.
✓ Branch 1 taken 38415466 times.
✓ Branch 2 taken 1472039 times.
✓ Branch 3 taken 2007 times.
39889512 if (get_qr(qr_OLD_TILE_INITIALIZATION) || tile == 0) tile = o_tile; //tile was initialized here before. It needs to be initialized here as well.
6690
6691
0/2
✗ Branch 0 not taken.
✗ Branch 1 not taken.
39889512 if(get_qr(qr_ANONE_NOANIM)
6692
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 39889512 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
39889512 && anim == aNONE && family != eeGUY)
6693 return;
6694
2/2
✓ Branch 0 taken 371376 times.
✓ Branch 1 taken 39518136 times.
39889512 int32_t newfrate = zc_max(frate,4);
6695 39889512 int32_t f4=abs(clk/(newfrate/4)); // casts clk to [0,1,2,3]
6696 39889512 int32_t f2=abs(clk/(newfrate/2)); // casts clk to [0,1]
6697
2/2
✓ Branch 0 taken 29898417 times.
✓ Branch 1 taken 9991095 times.
39889512 int32_t fx = get_qr(qr_NEWENEMYTILES) ? f4 : f2;
6698 39889512 tile = o_tile;
6699 39889512 int32_t basetile = o_tile;
6700 39889512 int32_t tilerows = 1; // How many rows of tiles? The Extend code needs to know.
6701 39889512 bool ignore_extend = false;
6702
35/40
✓ Branch 0 taken 220021 times.
✓ Branch 1 taken 8628 times.
✓ Branch 2 taken 199337 times.
✓ Branch 3 taken 1755010 times.
✓ Branch 4 taken 363745 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 140514 times.
✓ Branch 7 taken 366633 times.
✓ Branch 8 taken 836734 times.
✓ Branch 9 taken 3868 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 4981821 times.
✓ Branch 12 taken 69324 times.
✓ Branch 13 taken 53456 times.
✓ Branch 14 taken 38833 times.
✓ Branch 15 taken 455374 times.
✓ Branch 16 taken 1519575 times.
✓ Branch 17 taken 197042 times.
✗ Branch 18 not taken.
✓ Branch 19 taken 128880 times.
✓ Branch 20 taken 221637 times.
✓ Branch 21 taken 686882 times.
✓ Branch 22 taken 1690654 times.
✓ Branch 23 taken 1133827 times.
✗ Branch 24 not taken.
✓ Branch 25 taken 267131 times.
✓ Branch 26 taken 4117708 times.
✓ Branch 27 taken 7475916 times.
✗ Branch 28 not taken.
✓ Branch 29 taken 582791 times.
✓ Branch 30 taken 1178979 times.
✓ Branch 31 taken 880176 times.
✓ Branch 32 taken 218668 times.
✓ Branch 33 taken 1812060 times.
✓ Branch 34 taken 133344 times.
✓ Branch 35 taken 1433 times.
✓ Branch 36 taken 6953976 times.
✓ Branch 37 taken 747030 times.
✓ Branch 38 taken 276997 times.
✓ Branch 39 taken 171508 times.
39889512 switch(anim)
6703 {
6704
6705 case aDONGO:
6706 {
6707 69324 int32_t fr = stunclk>0 ? 16 : 8;
6708
6709
6/6
✓ Branch 0 taken 67426 times.
✓ Branch 1 taken 1898 times.
✓ Branch 2 taken 6720 times.
✓ Branch 3 taken 60706 times.
✓ Branch 4 taken 2240 times.
✓ Branch 5 taken 4480 times.
69324 if(!dying && clk2>0 && clk2<=64)
6710 {
6711 // bloated
6712
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 960 times.
✓ Branch 2 taken 960 times.
✓ Branch 3 taken 1664 times.
✓ Branch 4 taken 896 times.
4480 switch(dir)
6713 {
6714 case up:
6715 960 tile+=9;
6716 960 flip=0;
6717 960 xofs=0;
6718 960 dummy_int[1]=0; //no additional tiles
6719 960 break;
6720
6721 case down:
6722 960 tile+=7;
6723 960 flip=0;
6724 960 xofs=0;
6725 960 dummy_int[1]=0; //no additional tiles
6726 960 break;
6727
6728 case left:
6729 1664 flip=1;
6730 1664 tile+=4;
6731 1664 xofs=16;
6732 1664 dummy_int[1]=1; //second tile is next tile
6733 1664 break;
6734
6735 case right:
6736 896 flip=0;
6737 896 tile+=5;
6738 896 xofs=16;
6739 896 dummy_int[1]=-1; //second tile is previous tile
6740 896 break;
6741 }
6742 4480 }
6743
4/4
✓ Branch 0 taken 1898 times.
✓ Branch 1 taken 62946 times.
✓ Branch 2 taken 781 times.
✓ Branch 3 taken 1117 times.
64844 else if(!dying || clk2>19)
6744 {
6745 // normal
6746
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 13652 times.
✓ Branch 2 taken 15374 times.
✓ Branch 3 taken 19615 times.
✓ Branch 4 taken 15086 times.
63727 switch(dir)
6747 {
6748 case up:
6749 13652 tile+=8;
6750 13652 flip=(clk&fr)?1:0;
6751 13652 xofs=0;
6752 13652 dummy_int[1]=0; //no additional tiles
6753 13652 break;
6754
6755 case down:
6756 15374 tile+=6;
6757 15374 flip=(clk&fr)?1:0;
6758 15374 xofs=0;
6759 15374 dummy_int[1]=0; //no additional tiles
6760 15374 break;
6761
6762 case left:
6763 19615 flip=1;
6764 19615 tile+=(clk&fr)?2:0;
6765 19615 xofs=16;
6766 19615 dummy_int[1]=1; //second tile is next tile
6767 19615 break;
6768
6769 case right:
6770 15086 flip=0;
6771 15086 tile+=(clk&fr)?3:1;
6772 15086 xofs=16;
6773 15086 dummy_int[1]=-1; //second tile is next tile
6774 15086 break;
6775 }
6776 63727 }
6777 }
6778 69324 break;
6779
6780 case aNEWDONGO:
6781 {
6782 53456 int32_t fr4=0;
6783
6784
6/6
✓ Branch 0 taken 51564 times.
✓ Branch 1 taken 1892 times.
✓ Branch 2 taken 4128 times.
✓ Branch 3 taken 47436 times.
✓ Branch 4 taken 1376 times.
✓ Branch 5 taken 2752 times.
53456 if(!dying && clk2>0 && clk2<=64)
6785 {
6786 // bloated
6787
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2752 times.
2752 if(clk2>=0)
6788 {
6789 2752 fr4=3;
6790 2752 }
6791
6792
2/2
✓ Branch 0 taken 645 times.
✓ Branch 1 taken 2107 times.
2752 if(clk2>=16)
6793 {
6794 2107 fr4=2;
6795 2107 }
6796
6797
2/2
✓ Branch 0 taken 1333 times.
✓ Branch 1 taken 1419 times.
2752 if(clk2>=32)
6798 {
6799 1419 fr4=1;
6800 1419 }
6801
6802
2/2
✓ Branch 0 taken 2021 times.
✓ Branch 1 taken 731 times.
2752 if(clk2>=48)
6803 {
6804 731 fr4=0;
6805 731 }
6806
6807
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 256 times.
✓ Branch 2 taken 576 times.
✓ Branch 3 taken 704 times.
✓ Branch 4 taken 1216 times.
2752 switch(dir)
6808 {
6809 case up:
6810 256 xofs=0;
6811 256 tile+=8+fr4;
6812 256 dummy_int[1]=0; //no additional tiles
6813 256 break;
6814
6815 case down:
6816 576 xofs=0;
6817 576 tile+=12+fr4;
6818 576 dummy_int[1]=0; //no additional tiles
6819 576 break;
6820
6821 case left:
6822 704 tile+=29+(2*fr4);
6823 704 xofs=16;
6824 704 dummy_int[1]=-1; //second tile is previous tile
6825 704 break;
6826
6827 case right:
6828 1216 tile+=49+(2*fr4);
6829 1216 xofs=16;
6830 1216 dummy_int[1]=-1; //second tile is previous tile
6831 1216 break;
6832 }
6833 2752 }
6834
4/4
✓ Branch 0 taken 1892 times.
✓ Branch 1 taken 48812 times.
✓ Branch 2 taken 994 times.
✓ Branch 3 taken 898 times.
50704 else if(!dying || clk2>19)
6835 {
6836 // normal
6837
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 9234 times.
✓ Branch 2 taken 9871 times.
✓ Branch 3 taken 15025 times.
✓ Branch 4 taken 15676 times.
49806 switch(dir)
6838 {
6839 case up:
6840 9234 xofs=0;
6841 9234 tile+=((clk&12)>>2);
6842 9234 dummy_int[1]=0; //no additional tiles
6843 9234 break;
6844
6845 case down:
6846 9871 xofs=0;
6847 9871 tile+=4+((clk&12)>>2);
6848 9871 dummy_int[1]=0; //no additional tiles
6849 9871 break;
6850
6851 case left:
6852 15025 tile+=21+((clk&12)>>1);
6853 15025 xofs=16;
6854 15025 dummy_int[1]=-1; //second tile is previous tile
6855 15025 break;
6856
6857 case right:
6858 15676 flip=0;
6859 15676 tile+=41+((clk&12)>>1);
6860 15676 xofs=16;
6861 15676 dummy_int[1]=-1; //second tile is previous tile
6862 15676 break;
6863 }
6864 49806 }
6865 }
6866 53456 break;
6867
6868 case aDONGOBS:
6869 {
6870 38833 int32_t fr4=0;
6871
6872
6/6
✓ Branch 0 taken 37675 times.
✓ Branch 1 taken 1158 times.
✓ Branch 2 taken 4032 times.
✓ Branch 3 taken 33643 times.
✓ Branch 4 taken 1344 times.
✓ Branch 5 taken 2688 times.
38833 if(!dying && clk2>0 && clk2<=64)
6873 {
6874 // bloated
6875
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2688 times.
2688 if(clk2>=0)
6876 {
6877 2688 fr4=3;
6878 2688 }
6879
6880
2/2
✓ Branch 0 taken 630 times.
✓ Branch 1 taken 2058 times.
2688 if(clk2>=16)
6881 {
6882 2058 fr4=2;
6883 2058 }
6884
6885
2/2
✓ Branch 0 taken 1302 times.
✓ Branch 1 taken 1386 times.
2688 if(clk2>=32)
6886 {
6887 1386 fr4=1;
6888 1386 }
6889
6890
2/2
✓ Branch 0 taken 1974 times.
✓ Branch 1 taken 714 times.
2688 if(clk2>=48)
6891 {
6892 714 fr4=0;
6893 714 }
6894
6895
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 256 times.
✓ Branch 2 taken 384 times.
✓ Branch 3 taken 1024 times.
✓ Branch 4 taken 1024 times.
2688 switch(dir)
6896 {
6897 case up:
6898 256 tile+=28+fr4;
6899 256 yofs+=8;
6900 256 dummy_int[1]=-20; //second tile change
6901 256 dummy_int[2]=0; //new xofs change
6902 256 dummy_int[3]=-16; //new xofs change
6903 256 break;
6904
6905 case down:
6906 384 tile+=12+fr4;
6907 384 yofs-=8;
6908 384 dummy_int[1]=20; //second tile change
6909 384 dummy_int[2]=0; //new xofs change
6910 384 dummy_int[3]=16; //new xofs change
6911 384 break;
6912
6913 case left:
6914 1024 tile+=49+(2*fr4);
6915 1024 xofs+=8;
6916 1024 dummy_int[1]=-1; //second tile change
6917 1024 dummy_int[2]=-16; //new xofs change
6918 1024 dummy_int[3]=0; //new xofs change
6919 1024 break;
6920
6921 case right:
6922 1024 tile+=69+(2*fr4);
6923 1024 xofs+=8;
6924 1024 dummy_int[1]=-1; //second tile change
6925 1024 dummy_int[2]=-16; //new xofs change
6926 1024 dummy_int[3]=0; //new xofs change
6927 1024 break;
6928 }
6929 2688 }
6930
4/4
✓ Branch 0 taken 1158 times.
✓ Branch 1 taken 34987 times.
✓ Branch 2 taken 497 times.
✓ Branch 3 taken 661 times.
36145 else if(!dying || clk2>19)
6931 {
6932 // normal
6933
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 7136 times.
✓ Branch 2 taken 6672 times.
✓ Branch 3 taken 11075 times.
✓ Branch 4 taken 10601 times.
35484 switch(dir)
6934 {
6935 case up:
6936 7136 tile+=20+((clk&24)>>3);
6937 7136 yofs+=8;
6938 7136 dummy_int[1]=-20; //second tile change
6939 7136 dummy_int[2]=0; //new xofs change
6940 7136 dummy_int[3]=-16; //new xofs change
6941 7136 break;
6942
6943 case down:
6944 6672 tile+=4+((clk&24)>>3);
6945 6672 yofs-=8;
6946 6672 dummy_int[1]=20; //second tile change
6947 6672 dummy_int[2]=0; //new xofs change
6948 6672 dummy_int[3]=16; //new xofs change
6949 6672 break;
6950
6951 case left:
6952 11075 xofs=-8;
6953 11075 tile+=40+((clk&24)>>2);
6954 11075 dummy_int[1]=1; //second tile change
6955 11075 dummy_int[2]=16; //new xofs change
6956 11075 dummy_int[3]=0; //new xofs change
6957 11075 break;
6958
6959 case right:
6960 10601 tile+=60+((clk&24)>>2);
6961 10601 xofs=-8;
6962 10601 dummy_int[1]=1; //second tile change
6963 10601 dummy_int[2]=16; //new xofs change
6964 10601 dummy_int[3]=0; //new xofs change
6965 10601 break;
6966 }
6967 35484 }
6968 }
6969 38833 break;
6970
6971 case aWIZZ:
6972 {
6973 // if(d->misc1)
6974
2/2
✓ Branch 0 taken 182184 times.
✓ Branch 1 taken 273190 times.
455374 if(dmisc1)
6975 {
6976
2/2
✓ Branch 0 taken 91057 times.
✓ Branch 1 taken 91127 times.
182184 if(clk&8)
6977 {
6978 91127 ++tile;
6979 91127 }
6980 182184 }
6981 else
6982 {
6983
2/2
✓ Branch 0 taken 136701 times.
✓ Branch 1 taken 136489 times.
273190 if(frame&4)
6984 {
6985 136489 ++tile;
6986 136489 }
6987 }
6988
6989
4/4
✓ Branch 0 taken 76094 times.
✓ Branch 1 taken 157108 times.
✓ Branch 2 taken 145581 times.
✓ Branch 3 taken 76591 times.
455374 switch(dir)
6990 {
6991 case 9:
6992 case 15:
6993 case up:
6994 76094 tile+=2;
6995 76094 break;
6996
6997 case down:
6998 76591 break;
6999
7000 case 13:
7001 case left:
7002 157108 flip=1;
7003 157108 break;
7004
7005 default:
7006 145581 flip=0;
7007 145581 break;
7008 }
7009 }
7010 455374 break;
7011
7012 case aNEWWIZZ:
7013 {
7014 1519575 tiledir(dir,true);
7015
7016 // if(d->misc1) //walking wizzrobe
7017
2/2
✓ Branch 0 taken 742424 times.
✓ Branch 1 taken 777151 times.
1519575 if(dmisc1) //walking wizzrobe
7018 {
7019
2/2
✓ Branch 0 taken 373321 times.
✓ Branch 1 taken 369103 times.
742424 if(clk&8)
7020 {
7021 369103 tile+=2;
7022 369103 }
7023
7024
2/2
✓ Branch 0 taken 372085 times.
✓ Branch 1 taken 370339 times.
742424 if(clk&4)
7025 {
7026 370339 tile+=1;
7027 370339 }
7028
7029
2/4
✓ Branch 0 taken 742424 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 742424 times.
742424 if(!(dummy_bool[1]||dummy_bool[2])) //should never be charging or firing for these wizzrobes
7030 {
7031
2/2
✓ Branch 0 taken 663262 times.
✓ Branch 1 taken 79162 times.
742424 if(dummy_int[1]>0)
7032 {
7033 79162 tile+=40;
7034 79162 }
7035 742424 }
7036 742424 }
7037 else
7038 {
7039
4/4
✓ Branch 0 taken 710492 times.
✓ Branch 1 taken 66659 times.
✓ Branch 2 taken 167559 times.
✓ Branch 3 taken 542933 times.
777151 if(dummy_bool[1]||dummy_bool[2])
7040 {
7041 234218 tile+=20;
7042
7043
2/2
✓ Branch 0 taken 66650 times.
✓ Branch 1 taken 167568 times.
234218 if(dummy_bool[2])
7044 {
7045 167568 tile+=20;
7046 167568 }
7047 234218 }
7048
7049 777151 tile+=((frame>>1)&3);
7050 }
7051 }
7052 1519575 break;
7053
7054 case a3FRM:
7055 {
7056
2/2
✓ Branch 0 taken 46675 times.
✓ Branch 1 taken 150367 times.
197042 basetile = n_frame_n_dir(3, 0, (f4==3) ? 1 : f4);
7057 }
7058 197042 break;
7059
7060 case a3FRM4DIR:
7061 {
7062 basetile = n_frame_n_dir(3, 4, (f4==3) ? 1 : f4);
7063 }
7064 break;
7065
7066 case aVIRE:
7067 {
7068
2/2
✓ Branch 0 taken 99588 times.
✓ Branch 1 taken 29292 times.
128880 if(dir==up)
7069 {
7070 29292 tile+=2;
7071 29292 }
7072
7073 128880 tile+=fx;
7074 }
7075 128880 break;
7076
7077 case aROPE:
7078 {
7079 220021 tile+=(1-fx);
7080 220021 flip = dir==left ? 1:0;
7081 }
7082 220021 break;
7083
7084 case aZORA:
7085 {
7086 int32_t dl;
7087
7088
2/2
✓ Branch 0 taken 46739 times.
✓ Branch 1 taken 174898 times.
221637 if(clk<36)
7089 {
7090 46739 dl=clk+5;
7091 46739 goto waves2;
7092 }
7093
7094
2/2
✓ Branch 0 taken 82440 times.
✓ Branch 1 taken 92458 times.
174898 if(clk<36+66)
7095
2/2
✓ Branch 0 taken 50715 times.
✓ Branch 1 taken 31725 times.
82440 tile=(dir==up)?o_tile+1:o_tile;
7096 else
7097 {
7098 92458 dl=clk-36-66;
7099 waves2:
7100 139197 tile=((dl/11)&1)+s_tile;
7101 139197 basetile = s_tile;
7102 }
7103 }
7104 221637 break;
7105
7106 case aNEWZORA:
7107 {
7108 686882 f4=(clk/16)%4;
7109
7110 686882 tiledir(dir,true);
7111 int32_t dl;
7112
7113
4/4
✓ Branch 0 taken 485838 times.
✓ Branch 1 taken 201044 times.
✓ Branch 2 taken 249250 times.
✓ Branch 3 taken 236588 times.
686882 if((clk>35)&&(clk<36+67)) //surfaced
7114 {
7115
4/4
✓ Branch 0 taken 202239 times.
✓ Branch 1 taken 34349 times.
✓ Branch 2 taken 29164 times.
✓ Branch 3 taken 173075 times.
236588 if((clk>=(35+10))&&(clk<(38+56))) //mouth open
7116 {
7117 173075 tile+=80;
7118 173075 } //mouth closed
7119 else
7120 {
7121 63513 tile+=40;
7122 }
7123
7124 236588 tile+=f4;
7125 236588 }
7126 else
7127 {
7128
2/2
✓ Branch 0 taken 201044 times.
✓ Branch 1 taken 249250 times.
450294 if(clk<36)
7129 {
7130 201044 dl=clk+5;
7131 201044 }
7132 else
7133 {
7134 249250 dl=clk-36-66;
7135 }
7136
7137 450294 tile+=((dl/5)&3);
7138 }
7139 }
7140 686882 break;
7141
7142 case a4FRM4EYE:
7143 case a2FRM4EYE:
7144 case a4FRM8EYE:
7145 case a4FRM8EYEB: //big version
7146 case a4FRM4EYEB:
7147 {
7148 836734 tilerows = 2;
7149
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 836734 times.
836734 int fakex = x + 8*(zc_max(1,txsz)-1);
7150
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 836734 times.
836734 int fakey = y + 8*(zc_max(1,tysz)-1);
7151 double _MSVC2022_tmp1, _MSVC2022_tmp2;
7152 836734 double ddir=atan2_MSVC2022_FIX(double(fakey-(Hero.y)),double(Hero.x-fakex));
7153 836734 int32_t lookat=zc_oldrand()&15;
7154
7155
4/4
✓ Branch 0 taken 272091 times.
✓ Branch 1 taken 564643 times.
✓ Branch 2 taken 61317 times.
✓ Branch 3 taken 210774 times.
836734 if((ddir<=(((-5)*PI)/8))&&(ddir>(((-7)*PI)/8)))
7156 {
7157 210774 lookat=l_down;
7158 210774 }
7159
4/4
✓ Branch 0 taken 288167 times.
✓ Branch 1 taken 337793 times.
✓ Branch 2 taken 61317 times.
✓ Branch 3 taken 226850 times.
625960 else if((ddir<=(((-3)*PI)/8))&&(ddir>(((-5)*PI)/8)))
7160 {
7161 226850 lookat=down;
7162 226850 }
7163
4/4
✓ Branch 0 taken 170154 times.
✓ Branch 1 taken 228956 times.
✓ Branch 2 taken 61317 times.
✓ Branch 3 taken 108837 times.
399110 else if((ddir<=(((-1)*PI)/8))&&(ddir>(((-3)*PI)/8)))
7164 {
7165 108837 lookat=r_down;
7166 108837 }
7167
4/4
✓ Branch 0 taken 131712 times.
✓ Branch 1 taken 158561 times.
✓ Branch 2 taken 61317 times.
✓ Branch 3 taken 70395 times.
290273 else if((ddir<=(((1)*PI)/8))&&(ddir>(((-1)*PI)/8)))
7168 {
7169 70395 lookat=right;
7170 70395 }
7171
4/4
✓ Branch 0 taken 96384 times.
✓ Branch 1 taken 123494 times.
✓ Branch 2 taken 61317 times.
✓ Branch 3 taken 35067 times.
219878 else if((ddir<=(((3)*PI)/8))&&(ddir>(((1)*PI)/8)))
7172 {
7173 35067 lookat=r_up;
7174 35067 }
7175
4/4
✓ Branch 0 taken 86753 times.
✓ Branch 1 taken 98058 times.
✓ Branch 2 taken 61317 times.
✓ Branch 3 taken 25436 times.
184811 else if((ddir<=(((5)*PI)/8))&&(ddir>(((3)*PI)/8)))
7176 {
7177 25436 lookat=up;
7178 25436 }
7179
4/4
✓ Branch 0 taken 98120 times.
✓ Branch 1 taken 61255 times.
✓ Branch 2 taken 61317 times.
✓ Branch 3 taken 36803 times.
159375 else if((ddir<=(((7)*PI)/8))&&(ddir>(((5)*PI)/8)))
7180 {
7181 36803 lookat=l_up;
7182 36803 }
7183 else
7184 {
7185 122572 lookat=left;
7186 }
7187
7188 836734 int32_t dir2 = dir;
7189 836734 dir = lookat;
7190
3/6
✓ Branch 0 taken 836734 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 836734 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 836734 times.
836734 if (anim != a4FRM8EYEB && anim != a4FRM4EYEB) basetile = n_frame_n_dir(anim==a2FRM4EYE ? 2:4, anim==a4FRM8EYE ? 8 : 4, anim==a2FRM4EYE ? (f2&1):f4);
7191 else
7192 {
7193 tiledir_big(dir,(anim == a4FRM4EYEB));
7194 tile+=2*f4;
7195 ignore_extend = true;
7196 }
7197 836734 dir = dir2;
7198 }
7199 836734 break;
7200
7201 case aFLIP:
7202 {
7203 1690654 flip = f2&1;
7204 }
7205 1690654 break;
7206
7207 case a2FRM:
7208 {
7209 1133827 tile += (1-f2);
7210 }
7211 1133827 break;
7212
7213 case a2FRMB:
7214 {
7215 tile+= 2*(1-f2);
7216 ignore_extend = true;
7217 }
7218 break;
7219
7220 case a2FRM4DIR:
7221 {
7222 267131 basetile = n_frame_n_dir(2, 4, f2&1);
7223 }
7224 267131 break;
7225
7226 case a4FRM4DIRF:
7227 {
7228 4117708 basetile = n_frame_n_dir(4,4,f4);
7229
7230
2/2
✓ Branch 0 taken 2717716 times.
✓ Branch 1 taken 1399992 times.
4117708 if(clk2>0) //stopped to fire
7231 {
7232 1399992 tile+=20;
7233
7234
2/2
✓ Branch 0 taken 697526 times.
✓ Branch 1 taken 702466 times.
1399992 if(clk2<17) //firing
7235 {
7236 702466 tile+=20;
7237 702466 }
7238 1399992 }
7239 }
7240 4117708 break;
7241
7242 case a4FRM4DIR:
7243 {
7244 7475916 basetile = n_frame_n_dir(4,4,f4);
7245 }
7246 7475916 break;
7247
7248 case a4FRM8DIRF:
7249 {
7250 tilerows = 2;
7251 basetile = n_frame_n_dir(4,8,f4);
7252
7253 if(clk2>0) //stopped to fire
7254 {
7255 tile+=40;
7256
7257 if(clk2<17) //firing
7258 {
7259 tile+=40;
7260 }
7261 }
7262 }
7263 break;
7264
7265 case a4FRM8DIRB:
7266 case a4FRM8DIRFB:
7267 {
7268 3868 tilerows = 2;
7269 3868 tiledir_big(dir,false);
7270 3868 tile+=2*f4;
7271
3/4
✓ Branch 0 taken 3866 times.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 3866 times.
✗ Branch 3 not taken.
3868 if(clk2>0 && anim == a4FRM8DIRFB) //stopped to fire
7272 {
7273 tile+=80;
7274
7275 if(clk2<17) //firing
7276 {
7277 tile+=80;
7278 }
7279 }
7280 3868 ignore_extend = true;
7281 }
7282 3868 break;
7283
7284 case a4FRM4DIRB:
7285 case a4FRM4DIRFB:
7286 {
7287 tilerows = 2;
7288 tiledir_big(dir,true);
7289 tile+=2*f4;
7290 if(clk2>0 && anim == a4FRM4DIRFB) //stopped to fire
7291 {
7292 tile+=40;
7293
7294 if(clk2<17) //firing
7295 {
7296 tile+=40;
7297 }
7298 }
7299 ignore_extend = true;
7300 }
7301 break;
7302
7303 case aOCTO:
7304 {
7305
5/5
✓ Branch 0 taken 4152 times.
✓ Branch 1 taken 122459 times.
✓ Branch 2 taken 133448 times.
✓ Branch 3 taken 165605 times.
✓ Branch 4 taken 157127 times.
582791 switch(dir)
7306 {
7307 case up:
7308 122459 flip = 2;
7309 122459 break;
7310
7311 case down:
7312 133448 flip = 0;
7313 133448 break;
7314
7315 case left:
7316 165605 flip = 0;
7317 165605 tile += 2;
7318 165605 break;
7319
7320 case right:
7321 157127 flip = 1;
7322 157127 tile += 2;
7323 157127 break;
7324 }
7325
7326 582791 tile+=f2;
7327 }
7328 582791 break;
7329
7330 case aWALK:
7331 {
7332
5/5
✓ Branch 0 taken 5614 times.
✓ Branch 1 taken 248704 times.
✓ Branch 2 taken 267165 times.
✓ Branch 3 taken 331694 times.
✓ Branch 4 taken 325802 times.
1178979 switch(dir)
7333 {
7334 case up:
7335 248704 tile+=3;
7336 248704 flip = f2;
7337 248704 break;
7338
7339 case down:
7340 267165 tile+=2;
7341 267165 flip = f2;
7342 267165 break;
7343
7344 case left:
7345 331694 flip=1;
7346 331694 tile += f2;
7347 331694 break;
7348
7349 case right:
7350 325802 flip=0;
7351 325802 tile += f2;
7352 325802 break;
7353 }
7354 }
7355 1178979 break;
7356
7357 case aDWALK:
7358 {
7359
3/4
✓ Branch 0 taken 92330 times.
✓ Branch 1 taken 787846 times.
✓ Branch 2 taken 92330 times.
✗ Branch 3 not taken.
880176 if((get_qr(qr_BRKNSHLDTILES)) && (dummy_bool[1]==true))
7360 {
7361 tile=s_tile;
7362 basetile = s_tile;
7363 }
7364
7365
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 177728 times.
✓ Branch 2 taken 185581 times.
✓ Branch 3 taken 260885 times.
✓ Branch 4 taken 255982 times.
880176 switch(dir)
7366 {
7367 case up:
7368 177728 tile+=2;
7369 177728 flip=f2;
7370 177728 break;
7371
7372 case down:
7373 185581 flip=0;
7374 185581 tile+=(1-f2);
7375 185581 break;
7376
7377 case left:
7378 260885 flip=1;
7379 260885 tile+=(3+f2);
7380 260885 break;
7381
7382 case right:
7383 255982 flip=0;
7384 255982 tile+=(3+f2);
7385 255982 break;
7386 }
7387 }
7388 880176 break;
7389
7390 case aTEK:
7391 {
7392
2/2
✓ Branch 0 taken 139654 times.
✓ Branch 1 taken 79014 times.
218668 if(misc==0)
7393 {
7394 79014 tile += f2;
7395 79014 }
7396
2/2
✓ Branch 0 taken 72936 times.
✓ Branch 1 taken 66718 times.
139654 else if(misc!=1)
7397 {
7398 66718 ++tile;
7399 66718 }
7400 }
7401 218668 break;
7402
7403 case aNEWTEK:
7404 {
7405
2/2
✓ Branch 0 taken 474700 times.
✓ Branch 1 taken 1337360 times.
1812060 if(step<0) //up
7406 {
7407
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 235321 times.
✓ Branch 2 taken 239379 times.
474700 switch(clk3)
7408 {
7409 case left:
7410 235321 flip=0;
7411 235321 tile+=20;
7412 235321 break;
7413
7414 case right:
7415 239379 flip=0;
7416 239379 tile+=24;
7417 239379 break;
7418 }
7419 474700 }
7420
2/2
✓ Branch 0 taken 54741 times.
✓ Branch 1 taken 1282619 times.
1337360 else if(step==0)
7421 {
7422
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 40562 times.
✓ Branch 2 taken 14179 times.
54741 switch(clk3)
7423 {
7424 case left:
7425 40562 flip=0;
7426 40562 tile+=8;
7427 40562 break;
7428
7429 case right:
7430 14179 flip=0;
7431 14179 tile+=12;
7432 14179 break;
7433 }
7434 54741 } //down
7435 else
7436 {
7437
3/3
✓ Branch 0 taken 104875 times.
✓ Branch 1 taken 592792 times.
✓ Branch 2 taken 584952 times.
1282619 switch(clk3)
7438 {
7439 case left:
7440 592792 flip=0;
7441 592792 tile+=28;
7442 592792 break;
7443
7444 case right:
7445 584952 flip=0;
7446 584952 tile+=32;
7447 584952 break;
7448 }
7449 }
7450
7451
2/2
✓ Branch 0 taken 1232959 times.
✓ Branch 1 taken 579101 times.
1812060 if(misc==0)
7452 {
7453 579101 tile+=f4;
7454 579101 }
7455
2/2
✓ Branch 0 taken 577625 times.
✓ Branch 1 taken 655334 times.
1232959 else if(misc!=1)
7456 {
7457 655334 tile+=2;
7458 655334 }
7459 }
7460 1812060 break;
7461
7462 case aARMOS:
7463 {
7464
2/2
✓ Branch 0 taken 3227 times.
✓ Branch 1 taken 5401 times.
8628 if(!fading)
7465 {
7466 5401 tile += fx;
7467
7468
2/2
✓ Branch 0 taken 4204 times.
✓ Branch 1 taken 1197 times.
5401 if(dir==up)
7469 1197 tile += 2;
7470 5401 }
7471 }
7472 8628 break;
7473
7474 case aARMOS4:
7475 {
7476
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 28561 times.
✓ Branch 2 taken 85620 times.
✓ Branch 3 taken 42992 times.
✓ Branch 4 taken 42164 times.
199337 switch(dir)
7477 {
7478 case up:
7479 28561 flip=0;
7480 28561 break;
7481
7482 case down:
7483 85620 flip=0;
7484 85620 tile+=4;
7485 85620 break;
7486
7487 case left:
7488 42992 flip=0;
7489 42992 tile+=8;
7490 42992 break;
7491
7492 case right:
7493 42164 flip=0;
7494 42164 tile+=12;
7495 42164 break;
7496 }
7497
7498
2/2
✓ Branch 0 taken 59607 times.
✓ Branch 1 taken 139730 times.
199337 if(!fading)
7499 {
7500 139730 tile+=f4;
7501 139730 }
7502 }
7503 199337 break;
7504
7505 case aGHINI:
7506 {
7507
4/4
✓ Branch 0 taken 28037 times.
✓ Branch 1 taken 32092 times.
✓ Branch 2 taken 72763 times.
✓ Branch 3 taken 452 times.
133344 switch(dir)
7508 {
7509 case 8:
7510 case 9:
7511 case up:
7512 28037 ++tile;
7513 28037 flip=0;
7514 28037 break;
7515
7516 case 15:
7517 452 ++tile;
7518 452 flip=1;
7519 452 break;
7520
7521 case 10:
7522 case 11:
7523 case right:
7524 32092 flip=1;
7525 32092 break;
7526
7527 default:
7528 72763 flip=0;
7529 72763 break;
7530 }
7531 }
7532 133344 break;
7533
7534 case a2FRMPOS:
7535 {
7536 1755010 tile+=posframe;
7537 }
7538 1755010 break;
7539
7540 case a4FRMPOS4DIR:
7541 {
7542 363745 basetile = n_frame_n_dir(4,4,0);
7543 // tile+=f2;
7544 363745 tile+=posframe;
7545 }
7546 363745 break;
7547
7548 case a4FRMPOS4DIRF:
7549 {
7550 1433 basetile = n_frame_n_dir(4,4,0);
7551
7552
2/2
✓ Branch 0 taken 1236 times.
✓ Branch 1 taken 197 times.
1433 if(clk2>0) //stopped to fire
7553 {
7554 197 tile+=20;
7555
7556
2/2
✓ Branch 0 taken 133 times.
✓ Branch 1 taken 64 times.
197 if(clk2<17) //firing
7557 {
7558 64 tile+=20;
7559 64 }
7560 197 }
7561
7562 // tile+=f2;
7563 1433 tile+=posframe;
7564 }
7565 1433 break;
7566
7567 case a4FRMPOS8DIR:
7568 {
7569 6953976 tilerows = 2;
7570 6953976 int32_t n = tile;
7571 6953976 basetile = n_frame_n_dir(4,8,0);
7572 // tile+=f2;
7573 6953976 tile+=posframe;
7574 }
7575 6953976 break;
7576
7577 case a4FRMPOS8DIRF:
7578 {
7579 tilerows = 2;
7580 basetile = n_frame_n_dir(4,8,0);
7581
7582 if(clk2>0) //stopped to fire
7583 {
7584 tile+=40;
7585
7586 if(clk2<17) //firing
7587 {
7588 tile+=40;
7589 }
7590 }
7591
7592 tile+=posframe;
7593 }
7594 break;
7595
7596 case aNEWLEV:
7597 {
7598 747030 tiledir(dir,true);
7599
7600
4/5
✓ Branch 0 taken 258994 times.
✓ Branch 1 taken 115368 times.
✓ Branch 2 taken 48980 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 323688 times.
747030 switch(misc)
7601 {
7602 case -1:
7603 case 0:
7604 258994 return;
7605
7606 case 1:
7607
7608 // case 5: cs = d->misc2; break;
7609 case 5:
7610 115368 cs = dmisc2;
7611 115368 break;
7612
7613 case 2:
7614 case 4:
7615 48980 tile += 20;
7616 48980 break;
7617
7618 case 3:
7619 323688 tile += 40;
7620 323688 break;
7621 }
7622
7623 488036 tile+=f4;
7624 }
7625 488036 break;
7626
7627 case aLEV:
7628 {
7629 276997 f4 = ((clk/5)&1);
7630
7631
4/5
✓ Branch 0 taken 127945 times.
✓ Branch 1 taken 33336 times.
✓ Branch 2 taken 14658 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 101058 times.
276997 switch(misc)
7632 {
7633 case -1:
7634 case 0:
7635 127945 return;
7636
7637 case 1:
7638
7639 // case 5: tile += (f2) ? 1 : 0; cs = d->misc2; break;
7640 case 5:
7641 33336 tile += (f2) ? 1 : 0;
7642 33336 cs = dmisc2;
7643 33336 break;
7644
7645 case 2:
7646 case 4:
7647 14658 tile += 2;
7648 14658 break;
7649
7650 case 3:
7651 101058 tile += (f4) ? 4 : 3;
7652 101058 break;
7653 }
7654 }
7655 149052 break;
7656
7657 case aWALLM:
7658 {
7659
2/2
✓ Branch 0 taken 750 times.
✓ Branch 1 taken 139764 times.
140514 if(!dummy_bool[1])
7660 {
7661 139764 tile += f2;
7662 139764 }
7663 }
7664 140514 break;
7665
7666 case aNEWWALLM:
7667 {
7668 366633 int32_t tempdir=0;
7669
7670
4/4
✓ Branch 0 taken 38855 times.
✓ Branch 1 taken 43340 times.
✓ Branch 2 taken 8438 times.
✓ Branch 3 taken 276000 times.
366633 switch(misc)
7671 {
7672 case 1:
7673 case 2:
7674 43340 tempdir=clk3;
7675 43340 break;
7676
7677 case 3:
7678 case 4:
7679 case 5:
7680 38855 tempdir=dir;
7681 38855 break;
7682
7683 case 6:
7684 case 7:
7685 8438 tempdir=clk3^1;
7686 8438 break;
7687 }
7688
7689 366633 tiledir(tempdir,true);
7690
7691
2/2
✓ Branch 0 taken 1908 times.
✓ Branch 1 taken 364725 times.
366633 if(!dummy_bool[1])
7692 {
7693 364725 tile+=f4;
7694 364725 }
7695 }
7696 366633 break;
7697
7698 case a4FRMNODIR:
7699 {
7700 171508 tile+=f4;
7701 }
7702 171508 break;
7703
7704 } // switch(d->anim)
7705
7706 // flashing
7707 // if(d->flags & guy_flashing)
7708
2/2
✓ Branch 0 taken 38758945 times.
✓ Branch 1 taken 743628 times.
39502573 if(flags & guy_flashing)
7709 {
7710 743628 cs = (frame&3) + 6;
7711 743628 }
7712
7713
2/2
✓ Branch 0 taken 39091625 times.
✓ Branch 1 taken 410948 times.
39502573 if(flags&guy_transparent)
7714 {
7715 410948 drawstyle=1;
7716 410948 }
7717
7718 39502573 int32_t change = tile-basetile;
7719
7720
3/6
✓ Branch 0 taken 1942794 times.
✓ Branch 1 taken 37559779 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1942794 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
39502573 if(extend > 2 && (!ignore_extend || get_qr(qr_BROKEN_BIG_ENEMY_ANIMATION)))
7721 {
7722
2/2
✓ Branch 0 taken 1681192 times.
✓ Branch 1 taken 261602 times.
1942794 if(basetile/TILES_PER_ROW==(basetile+((txsz*change)/tilerows))/TILES_PER_ROW)
7723 {
7724 1681192 tile=basetile+txsz*change;
7725 1681192 }
7726 else
7727 {
7728 261602 tile=basetile+(txsz*change)+((tysz-1)*TILES_PER_ROW)*(((basetile+txsz*change)/TILES_PER_ROW)-(basetile/TILES_PER_ROW));
7729 }
7730 1942794 }
7731 else
7732 {
7733 37559779 tile=basetile+change;
7734 }
7735 39891825 }
7736
7737 81078 int32_t enemy::wpnsfx(int32_t wpn)
7738 {
7739
3/3
✓ Branch 0 taken 22419 times.
✓ Branch 1 taken 40952 times.
✓ Branch 2 taken 17707 times.
81078 switch (wpn)
7740 {
7741 case ewFireTrail:
7742 case ewFlame:
7743 case ewFlame2Trail:
7744 case ewFlame2:
7745 case ewWind:
7746 case ewMagic:
7747 case ewIce:
7748 22419 return firesfx;
7749
7750 case ewRock:
7751 case ewFireball2:
7752 case ewFireball:
7753
2/2
✓ Branch 0 taken 5494 times.
✓ Branch 1 taken 35458 times.
40952 if (get_qr(qr_MORESOUNDS)) return firesfx;
7754 35458 break;
7755 }
7756
7757 53165 return 0;
7758 81078 }
7759
7760 76625588 int32_t enemy::run_script(int32_t mode)
7761 {
7762
3/4
✓ Branch 0 taken 256 times.
✓ Branch 1 taken 76625332 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 256 times.
76625588 if(switch_hooked && !get_qr(qr_SWITCHOBJ_RUN_SCRIPT)) return RUNSCRIPT_OK;
7763
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 76625332 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
76625332 if (script <= 0 || FFCore.getQuestHeaderInfo(vZelda) < 0x255 || FFCore.system_suspend[susptNPCSCRIPTS])
7764 76625332 return RUNSCRIPT_OK;
7765 auto scrty = *get_scrtype();
7766 auto uid = getUID();
7767 if(!FFCore.doscript(scrty,uid))
7768 return RUNSCRIPT_OK;
7769 int32_t ret = RUNSCRIPT_OK;
7770 bool& waitdraw = FFCore.waitdraw(scrty, uid);
7771 switch(mode)
7772 {
7773 case MODE_NORMAL:
7774 return ZScriptVersion::RunScript(ScriptType::NPC, script, uid);
7775 case MODE_WAITDRAW:
7776 if(waitdraw)
7777 {
7778 ret = ZScriptVersion::RunScript(ScriptType::NPC, script, uid);
7779 waitdraw = false;
7780 }
7781 break;
7782 }
7783 return ret;
7784 76625588 }
7785 ALLEGRO_COLOR enemy::hitboxColor(byte opacity) const
7786 {
7787 return al_map_rgba(255,0,0,opacity);
7788 }
7789
7790 // good guys, fires, fairy, and other non-enemies
7791 // based on enemy class b/c guys in dungeons act sort of like enemies
7792 // also easier to manage all the guys this way
7793 2178 guy::guy(zfix X,zfix Y,int32_t Id,int32_t Clk,bool mg) : enemy(X,Y,Id,Clk)
7794 2178 {
7795 2178 mainguy=mg;
7796 2178 canfreeze=false;
7797 2178 dir=down;
7798
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2178 times.
✓ Branch 2 taken 2178 times.
✗ Branch 3 not taken.
2178 yofs=(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
7799 2178 hxofs=2;
7800 2178 hzsz=8;
7801 2178 hit_width=12;
7802 2178 hit_height=17;
7803
7804
10/12
✓ Branch 0 taken 2178 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2178 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 765 times.
✓ Branch 5 taken 1413 times.
✓ Branch 6 taken 743 times.
✓ Branch 7 taken 22 times.
✓ Branch 8 taken 276 times.
✓ Branch 9 taken 467 times.
✓ Branch 10 taken 16 times.
✓ Branch 11 taken 260 times.
2178 if(!superman && (!isdungeon() || id==gFAIRY || id==gFIRE || id==gZELDA))
7805 {
7806 1918 superman = 1;
7807 1918 hxofs=1000;
7808 1918 }
7809 2178 }
7810
7811 938182 bool guy::animate(int32_t index)
7812 {
7813
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 938182 times.
938182 if(switch_hooked) return enemy::animate(index);
7814
6/6
✓ Branch 0 taken 539004 times.
✓ Branch 1 taken 399178 times.
✓ Branch 2 taken 8214 times.
✓ Branch 3 taken 530790 times.
✓ Branch 4 taken 7017 times.
✓ Branch 5 taken 1197 times.
938182 if(mainguy && clk==0 && misc==0)
7815 {
7816 1197 setupscreen();
7817 1197 misc = 1;
7818 1197 }
7819
7820
4/4
✓ Branch 0 taken 539004 times.
✓ Branch 1 taken 399178 times.
✓ Branch 2 taken 538676 times.
✓ Branch 3 taken 328 times.
938182 if(mainguy && fadeclk==0)
7821 328 return true;
7822
7823 937854 hp=256; // good guys never die...
7824
7825
4/4
✓ Branch 0 taken 922 times.
✓ Branch 1 taken 936932 times.
✓ Branch 2 taken 906 times.
✓ Branch 3 taken 16 times.
937854 if(hclk && !clk2)
7826 {
7827 // but if they get hit...
7828 16 ++clk2; // only do this once
7829
7830
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 7 times.
16 if(!get_qr(qr_NOGUYFIRES))
7831 {
7832 7 addenemy(BSZ?64:72,68,eSHOOTFBALL,0);
7833 7 addenemy(BSZ?176:168,68,eSHOOTFBALL,0);
7834 7 }
7835 16 }
7836
7837 937854 return enemy::animate(index);
7838 938182 }
7839
7840 941952 void guy::draw(BITMAP *dest)
7841 {
7842 941952 update_enemy_frame();
7843
7844
6/6
✓ Branch 0 taken 542567 times.
✓ Branch 1 taken 399385 times.
✓ Branch 2 taken 22779 times.
✓ Branch 3 taken 519788 times.
✓ Branch 4 taken 10998 times.
✓ Branch 5 taken 11781 times.
941952 if(!mainguy || fadeclk<0 || fadeclk&1)
7845 930171 enemy::draw(dest);
7846 941952 }
7847
7848 759 eFire::eFire(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
7849 759 {
7850 759 clk4=0;
7851
4/8
✓ Branch 0 taken 759 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 759 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 759 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 759 times.
✗ Branch 7 not taken.
759 shield= (flags&(guy_shield_left | guy_shield_right | guy_shield_back |guy_shield_front)) != 0;
7852 // Spawn type
7853
2/4
✓ Branch 0 taken 759 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 759 times.
759 if(flags & guy_fade_flicker)
7854 {
7855 clk=0;
7856 superman = 1;
7857 fading=fade_flicker;
7858 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
7859 dir=down;
7860
7861 if(!canmove(down,(zfix)8,spw_none,false))
7862 clk3=int32_t(13.0/step);
7863 }
7864
3/4
✓ Branch 0 taken 759 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 676 times.
✓ Branch 3 taken 83 times.
759 else if(flags & guy_fade_instant)
7865 {
7866 83 clk=0;
7867 83 }
7868
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 759 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
759 if (SIZEflags != 0) init_size_flags();;
7869 759 }
7870
7871 167471 bool eFire::animate(int32_t index)
7872 {
7873
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 167471 times.
167471 if(switch_hooked) return enemy::animate(index);
7874
2/4
✓ Branch 0 taken 167471 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 167471 times.
167471 if(fallclk||drownclk) return enemy::animate(index);
7875
2/2
✓ Branch 0 taken 165755 times.
✓ Branch 1 taken 1716 times.
167471 if(fading)
7876 {
7877
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 1715 times.
1716 if(++clk4 > 60)
7878 {
7879 1 clk4=0;
7880 1 superman=0;
7881 1 fading=0;
7882
7883
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1 if(flags&guy_armos && z==0 && fakez==0)
7884 removearmos(x,y,ffcactivated);
7885
7886 1 clk2=0;
7887
7888
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if(!canmove(down,(zfix)8,spw_none,false))
7889 {
7890 1 dir=0;
7891 1 y = y.getInt() & 0xF0;
7892 1 }
7893
7894 1 return Dead(index);
7895 }
7896
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 1715 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
1715 else if(flags&guy_armos && z==0 && fakez==0 && clk==0)
7897 removearmos(x,y,ffcactivated);
7898 1715 }
7899
7900 167470 return enemy::animate(index);
7901 167471 }
7902
7903 351657 void eFire::draw(BITMAP *dest)
7904 {
7905 351657 update_enemy_frame();
7906 351657 enemy::draw(dest);
7907 351657 }
7908
7909 415 int32_t eFire::takehit(weapon *w, weapon* realweap)
7910 {
7911 415 int32_t wpnId = w->id;
7912 415 int32_t wpnDir = w->dir;
7913
7914
3/4
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 408 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7 times.
415 if(wpnId==wHammer && shield && (flags & guy_bkshield)
7915 && ((flags&guy_shield_front && wpnDir==(dir^down)) || (flags&guy_shield_back && wpnDir==(dir^up))
7916 || (flags&guy_shield_left && wpnDir==(dir^left)) || (flags&guy_shield_right && wpnDir==(dir^right))))
7917 {
7918 shield = false;
7919 flags &= ~(guy_shield_left|guy_shield_right|guy_shield_back|guy_shield_front);
7920
7921 if(get_qr(qr_BRKNSHLDTILES))
7922 o_tile=s_tile;
7923 }
7924
7925 415 int32_t ret = enemy::takehit(w,realweap);
7926 415 return ret;
7927 }
7928
7929 void eFire::break_shield()
7930 {
7931 if(!shield)
7932 return;
7933
7934 flags&=~(guy_shield_front | guy_shield_back | guy_shield_left | guy_shield_right);
7935 shield=false;
7936
7937 if(get_qr(qr_BRKNSHLDTILES))
7938 o_tile=s_tile;
7939 }
7940
7941 7314 eOther::eOther(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
7942 7314 {
7943 7314 clk4=0;
7944
4/8
✓ Branch 0 taken 7314 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7314 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 7314 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 7314 times.
✗ Branch 7 not taken.
7314 shield= (flags&(guy_shield_left | guy_shield_right | guy_shield_back |guy_shield_front)) != 0;
7945
7946 // Spawn type
7947
2/4
✓ Branch 0 taken 7314 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 7314 times.
7314 if(flags & guy_fade_flicker)
7948 {
7949 clk=0;
7950 superman = 1;
7951 fading=fade_flicker;
7952 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
7953 dir=down;
7954
7955 if(!canmove(down,(zfix)8,spw_none,false))
7956 clk3=int32_t(13.0/step);
7957 }
7958
3/4
✓ Branch 0 taken 7314 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6133 times.
✓ Branch 3 taken 1181 times.
7314 else if(flags & guy_fade_instant)
7959 {
7960 1181 clk=0;
7961 1181 }
7962
3/4
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 7307 times.
✓ Branch 2 taken 7 times.
✗ Branch 3 not taken.
7314 if (SIZEflags != 0) init_size_flags();;
7963 7314 }
7964
7965 1872314 bool eOther::animate(int32_t index)
7966 {
7967
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1872314 times.
1872314 if(switch_hooked) return enemy::animate(index);
7968
3/4
✓ Branch 0 taken 1870797 times.
✓ Branch 1 taken 1517 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1870797 times.
1872314 if(fallclk||drownclk) return enemy::animate(index);
7969
2/2
✓ Branch 0 taken 1862383 times.
✓ Branch 1 taken 8414 times.
1870797 if(fading)
7970 {
7971
2/2
✓ Branch 0 taken 27 times.
✓ Branch 1 taken 8387 times.
8414 if(++clk4 > 60)
7972 {
7973 27 clk4=0;
7974 27 superman=0;
7975 27 fading=0;
7976
7977
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 27 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
27 if(flags&guy_armos && z==0 && fakez==0)
7978 removearmos(x,y,ffcactivated);
7979
7980 27 clk2=0;
7981
7982
2/2
✓ Branch 0 taken 25 times.
✓ Branch 1 taken 2 times.
27 if(!canmove(down,(zfix)8,spw_none,false))
7983 {
7984 2 dir=0;
7985 2 y = y.getInt() & 0xF0;
7986 2 }
7987
7988 27 return Dead(index);
7989 }
7990
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 8387 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
8387 else if(flags&guy_armos && z==0 && fakez==0 && clk==0)
7991 removearmos(x,y,ffcactivated);
7992 8387 }
7993
7994 1870770 return enemy::animate(index);
7995 1872314 }
7996
7997 1975750 void eOther::draw(BITMAP *dest)
7998 {
7999 1975750 update_enemy_frame();
8000 1975750 enemy::draw(dest);
8001 1975750 }
8002
8003 14188 int32_t eOther::takehit(weapon *w, weapon* realweap)
8004 {
8005 14188 int32_t wpnId = w->id;
8006 14188 int32_t wpnDir = w->dir;
8007
8008
3/4
✓ Branch 0 taken 25 times.
✓ Branch 1 taken 14163 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 25 times.
14188 if(wpnId==wHammer && shield && (flags & guy_bkshield)
8009 && ((flags&guy_shield_front && wpnDir==(dir^down)) || (flags&guy_shield_back && wpnDir==(dir^up))
8010 || (flags&guy_shield_left && wpnDir==(dir^left)) || (flags&guy_shield_right && wpnDir==(dir^right))))
8011 {
8012 shield = false;
8013 flags &= ~(guy_shield_left|guy_shield_right|guy_shield_back|guy_shield_front);
8014
8015 if(get_qr(qr_BRKNSHLDTILES))
8016 o_tile=s_tile;
8017 }
8018
8019 14188 int32_t ret = enemy::takehit(w,realweap);
8020 14188 return ret;
8021 }
8022
8023 void eOther::break_shield()
8024 {
8025 if(!shield)
8026 return;
8027
8028 flags&=~(guy_shield_front | guy_shield_back | guy_shield_left | guy_shield_right);
8029 shield=false;
8030
8031 if(get_qr(qr_BRKNSHLDTILES))
8032 o_tile=s_tile;
8033 }
8034
8035
8036 eScript::eScript(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
8037 {
8038 clk4=0;
8039 shield= (flags&(guy_shield_left | guy_shield_right | guy_shield_back |guy_shield_front)) != 0;
8040
8041 // Spawn type
8042 if(flags & guy_fade_flicker)
8043 {
8044 clk=0;
8045 superman = 1;
8046 fading=fade_flicker;
8047 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
8048 dir=down;
8049
8050 if(!canmove(down,(zfix)8,spw_none,false))
8051 clk3=int32_t(13.0/step);
8052 }
8053 else if(flags & guy_fade_instant)
8054 {
8055 clk=0;
8056 }
8057 if (SIZEflags != 0) init_size_flags();;
8058 }
8059
8060 bool eScript::animate(int32_t index)
8061 {
8062 if(switch_hooked) return enemy::animate(index);
8063 if(fallclk||drownclk) return enemy::animate(index);
8064 if(fading)
8065 {
8066 if(++clk4 > 60)
8067 {
8068 clk4=0;
8069 superman=0;
8070 fading=0;
8071
8072 if(flags&guy_armos && z==0 && fakez==0)
8073 removearmos(x,y,ffcactivated);
8074
8075 clk2=0;
8076
8077 if(!canmove(down,(zfix)8,spw_none,false))
8078 {
8079 dir=0;
8080 y = y.getInt() & 0xF0;
8081 }
8082
8083 return Dead(index);
8084 }
8085 else if(flags&guy_armos && z==0 && fakez==0 && clk==0)
8086 removearmos(x,y,ffcactivated);
8087 }
8088
8089 return enemy::animate(index);
8090 }
8091
8092 void eScript::draw(BITMAP *dest)
8093 {
8094 update_enemy_frame();
8095 enemy::draw(dest);
8096 }
8097
8098 int32_t eScript::takehit(weapon *w, weapon* realweap)
8099 {
8100 int32_t wpnId = w->id;
8101 int32_t wpnDir = w->dir;
8102
8103 if(wpnId==wHammer && shield && (flags & guy_bkshield)
8104 && ((flags&guy_shield_front && wpnDir==(dir^down)) || (flags&guy_shield_back && wpnDir==(dir^up))
8105 || (flags&guy_shield_left && wpnDir==(dir^left)) || (flags&guy_shield_right && wpnDir==(dir^right))))
8106 {
8107 shield = false;
8108 flags &= ~(guy_shield_left|guy_shield_right|guy_shield_back|guy_shield_front);
8109
8110 if(get_qr(qr_BRKNSHLDTILES))
8111 o_tile=s_tile;
8112 }
8113
8114 int32_t ret = enemy::takehit(w,realweap);
8115 return ret;
8116 }
8117
8118 void eScript::break_shield()
8119 {
8120 if(!shield)
8121 return;
8122
8123 flags&=~(guy_shield_front | guy_shield_back | guy_shield_left | guy_shield_right);
8124 shield=false;
8125
8126 if(get_qr(qr_BRKNSHLDTILES))
8127 o_tile=s_tile;
8128 }
8129
8130
8131 eFriendly::eFriendly(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
8132 {
8133 clk4=0;
8134 hyofs = -32768; //No hitbox initially.
8135 shield= (flags&(guy_shield_left | guy_shield_right | guy_shield_back |guy_shield_front)) != 0;
8136
8137 // Spawn type
8138 if(flags & guy_fade_flicker)
8139 {
8140 clk=0;
8141 superman = 1;
8142 fading=fade_flicker;
8143 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
8144 dir=down;
8145
8146 if(!canmove(down,(zfix)8,spw_none,false))
8147 clk3=int32_t(13.0/step);
8148 }
8149 else if(flags & guy_fade_instant)
8150 {
8151 clk=0;
8152 }
8153 if (SIZEflags != 0) init_size_flags();;
8154 }
8155
8156 bool eFriendly::animate(int32_t index)
8157 {
8158 if(switch_hooked) return enemy::animate(index);
8159 if(fallclk||drownclk) return enemy::animate(index);
8160 if(fading)
8161 {
8162 if(++clk4 > 60)
8163 {
8164 clk4=0;
8165 superman=0;
8166 fading=0;
8167
8168 if(flags&guy_armos && z==0 && fakez==0)
8169 removearmos(x,y,ffcactivated);
8170
8171 clk2=0;
8172
8173 if(!canmove(down,(zfix)8,spw_none,false))
8174 {
8175 dir=0;
8176 y = y.getInt() & 0xF0;
8177 }
8178
8179 return Dead(index);
8180 }
8181 else if(flags&guy_armos && z==0 && fakez==0 && clk==0)
8182 removearmos(x,y,ffcactivated);
8183 }
8184
8185 return enemy::animate(index);
8186 }
8187
8188 void eFriendly::draw(BITMAP *dest)
8189 {
8190 update_enemy_frame();
8191 enemy::draw(dest);
8192 }
8193
8194 int32_t eFriendly::takehit(weapon *w, weapon* realweap)
8195 {
8196 int32_t wpnId = w->id;
8197 int32_t wpnDir = w->dir;
8198
8199 if(wpnId==wHammer && shield && (flags & guy_bkshield)
8200 && ((flags&guy_shield_front && wpnDir==(dir^down)) || (flags&guy_shield_back && wpnDir==(dir^up))
8201 || (flags&guy_shield_left && wpnDir==(dir^left)) || (flags&guy_shield_right && wpnDir==(dir^right))))
8202 {
8203 shield = false;
8204 flags &= ~(guy_shield_left|guy_shield_right|guy_shield_back|guy_shield_front);
8205
8206 if(get_qr(qr_BRKNSHLDTILES))
8207 o_tile=s_tile;
8208 }
8209
8210 int32_t ret = enemy::takehit(w,realweap);
8211 return ret;
8212 }
8213
8214 void eFriendly::break_shield()
8215 {
8216 if(!shield)
8217 return;
8218
8219 flags&=~(guy_shield_front | guy_shield_back | guy_shield_left | guy_shield_right);
8220 shield=false;
8221
8222 if(get_qr(qr_BRKNSHLDTILES))
8223 o_tile=s_tile;
8224 }
8225
8226
8227 779014 void enemy::removearmos(int32_t ax,int32_t ay, word ffcactive)
8228 {
8229
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 779014 times.
779014 if (ffcactive)
8230 {
8231 removearmosffc(ffcactive-1);
8232 return;
8233 }
8234
2/2
✓ Branch 0 taken 778034 times.
✓ Branch 1 taken 980 times.
779014 if(did_armos)
8235 {
8236 778034 return;
8237 }
8238
8239 980 did_armos=true;
8240 980 ax&=0xF0;
8241 980 ay&=0xF0;
8242 980 int32_t cd = (ax>>4)+ay;
8243 980 int32_t f = MAPFLAG(ax,ay);
8244 980 int32_t f2 = MAPCOMBOFLAG(ax,ay);
8245
8246
2/2
✓ Branch 0 taken 840 times.
✓ Branch 1 taken 140 times.
980 if(combobuf[tmpscr->data[cd]].type!=cARMOS)
8247 {
8248 840 return;
8249 }
8250
8251 140 tmpscr->data[cd] = tmpscr->undercombo;
8252 140 tmpscr->cset[cd] = tmpscr->undercset;
8253 140 tmpscr->sflag[cd] = 0;
8254
8255
3/4
✓ Branch 0 taken 118 times.
✓ Branch 1 taken 22 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 118 times.
140 if(f == mfARMOS_SECRET || f2 == mfARMOS_SECRET)
8256 {
8257 22 tmpscr->data[cd] = tmpscr->secretcombo[sSTAIRS];
8258 22 tmpscr->cset[cd] = tmpscr->secretcset[sSTAIRS];
8259 22 tmpscr->sflag[cd]=tmpscr->secretflag[sSTAIRS];
8260 22 sfx(tmpscr->secretsfx);
8261 22 }
8262
8263
3/4
✓ Branch 0 taken 137 times.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 137 times.
140 if(f == mfARMOS_ITEM || f2 == mfARMOS_ITEM)
8264 {
8265
2/6
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
3 if(!getmapflag((currscr < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM) || (tmpscr->flags9&fBELOWRETURN))
8266 {
8267 3 additem(ax,ay,tmpscr->catchall, (ipONETIME2 + ipBIGRANGE) | ((tmpscr->flags3&fHOLDITEM) ? ipHOLDUP : 0) | ((tmpscr->flags8&fITEMSECRET) ? ipSECRETS : 0));
8268 3 sfx(tmpscr->secretsfx);
8269 3 }
8270 3 }
8271
8272 140 putcombo(scrollbuf,ax,ay,tmpscr->data[cd],tmpscr->cset[cd]);
8273 779014 }
8274
8275 void enemy::removearmosffc(int32_t pos)
8276 {
8277 if(did_armos)
8278 {
8279 return;
8280 }
8281
8282 did_armos=true;
8283 ffcdata& ffc = tmpscr->ffcs[pos];
8284 newcombo const& cmb = combobuf[ffc.data];
8285 int32_t f2 = cmb.flag;
8286
8287 if(cmb.type!=cARMOS)
8288 {
8289 return;
8290 }
8291
8292 zc_ffc_set(ffc, tmpscr->undercombo);
8293 ffc.cset = tmpscr->undercset;
8294
8295 if(f2 == mfARMOS_SECRET)
8296 {
8297 zc_ffc_set(ffc, tmpscr->secretcombo[sSTAIRS]);
8298 ffc.cset = tmpscr->secretcset[sSTAIRS];
8299 sfx(tmpscr->secretsfx);
8300 }
8301
8302 if(f2 == mfARMOS_ITEM)
8303 {
8304 if(!getmapflag((currscr < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM) || (tmpscr->flags9&fBELOWRETURN))
8305 {
8306 additem(ffc.x,ffc.y,tmpscr->catchall, (ipONETIME2 + ipBIGRANGE) | ((tmpscr->flags3&fHOLDITEM) ? ipHOLDUP : 0) | ((tmpscr->flags8&fITEMSECRET) ? ipSECRETS : 0));
8307 sfx(tmpscr->secretsfx);
8308 }
8309 }
8310
8311 putcombo(scrollbuf,ffc.x,ffc.y,ffc.data,ffc.cset);
8312 }
8313
8314
8315 461 eGhini::eGhini(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
8316 461 {
8317 461 fading=fade_flicker;
8318
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 461 times.
461 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
8319 461 dir=12;
8320 461 movestatus=1;
8321
1/2
✓ Branch 0 taken 461 times.
✗ Branch 1 not taken.
461 step=0;
8322 461 clk=0;
8323 461 clk4=0;
8324
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 461 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
461 if (SIZEflags != 0) init_size_flags();;
8325 461 }
8326
8327 117025 bool eGhini::animate(int32_t index)
8328 {
8329
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 117025 times.
117025 if(switch_hooked) return enemy::animate(index);
8330
2/4
✓ Branch 0 taken 117025 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 117025 times.
117025 if(fallclk||drownclk) return enemy::animate(index);
8331
2/2
✓ Branch 0 taken 50 times.
✓ Branch 1 taken 116975 times.
117025 if(dying)
8332 50 return Dead(index);
8333
8334
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116975 times.
116975 if(dmisc1)
8335 {
8336
2/2
✓ Branch 0 taken 89752 times.
✓ Branch 1 taken 27223 times.
116975 if(misc)
8337 {
8338
2/2
✓ Branch 0 taken 34899 times.
✓ Branch 1 taken 54853 times.
89752 if(clk4>160)
8339 54853 misc=2;
8340
8341
2/2
✓ Branch 0 taken 34899 times.
✓ Branch 1 taken 54853 times.
89752 floater_walk((misc==1)?0:rate,hrate,zslongToFix(dstep*100),zslongToFix(dstep*10),10,dmisc16,dmisc17); //120,10);
8342 89752 removearmos(x,y,ffcactivated);
8343 89752 }
8344
2/2
✓ Branch 0 taken 26798 times.
✓ Branch 1 taken 425 times.
27223 else if(clk4>=60)
8345 {
8346 425 misc=1;
8347 425 clk3=32;
8348 425 fading=0;
8349
1/2
✓ Branch 0 taken 425 times.
✗ Branch 1 not taken.
425 if (ffcactivated > 0)
8350 {
8351 guygridffc[ffcactivated-1] = 0;
8352 removearmosffc(ffcactivated-1);
8353 }
8354 else
8355 {
8356 425 guygrid[(int32_t(y)&0xF0)+(int32_t(x)>>4)]=0;
8357 425 removearmos(x,y);
8358 }
8359 425 }
8360 116975 }
8361
8362 116975 clk4++;
8363
8364 116975 return enemy::animate(index);
8365 117025 }
8366
8367 238808 void eGhini::draw(BITMAP *dest)
8368 {
8369 238808 update_enemy_frame();
8370 238808 enemy::draw(dest);
8371 238808 }
8372
8373 2 void eGhini::kickbucket()
8374 {
8375 2 hp=-1000; // don't call death_sfx()
8376 2 }
8377
8378
2/4
✓ Branch 0 taken 5196 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5196 times.
✗ Branch 3 not taken.
10392 eTektite::eTektite(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
8379 5196 {
8380
1/2
✓ Branch 0 taken 5196 times.
✗ Branch 1 not taken.
5196 old_y=y;
8381 5196 dir=down;
8382 5196 misc=1;
8383 5196 clk=-15;
8384
8385
2/2
✓ Branch 0 taken 2645 times.
✓ Branch 1 taken 2551 times.
5196 if(!BSZ)
8386
1/2
✓ Branch 0 taken 2645 times.
✗ Branch 1 not taken.
2645 clk*=zc_oldrand()%3+1;
8387
8388 // avoid divide by 0 errors
8389
1/2
✓ Branch 0 taken 5196 times.
✗ Branch 1 not taken.
5196 if(dmisc1 == 0)
8390 dmisc1 = 24;
8391
8392
1/2
✓ Branch 0 taken 5196 times.
✗ Branch 1 not taken.
5196 if(dmisc2 == 0)
8393 dmisc2 = 3;
8394
8395 //nets+760;
8396
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 5196 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
5196 if (SIZEflags != 0) init_size_flags();;
8397 5196 }
8398
8399 1435270 bool eTektite::animate(int32_t index)
8400 {
8401
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1435270 times.
1435270 if(switch_hooked) return enemy::animate(index);
8402
4/4
✓ Branch 0 taken 1426328 times.
✓ Branch 1 taken 8942 times.
✓ Branch 2 taken 8942 times.
✓ Branch 3 taken 1423910 times.
1435270 if(fallclk||drownclk) return enemy::animate(index);
8403
2/2
✓ Branch 0 taken 26667 times.
✓ Branch 1 taken 1397243 times.
1423910 if(dying)
8404 26667 return Dead(index);
8405
8406
2/2
✓ Branch 0 taken 1360175 times.
✓ Branch 1 taken 37068 times.
1397243 if(clk==0)
8407 {
8408 37068 removearmos(x,y,ffcactivated);
8409 37068 }
8410
8411
2/2
✓ Branch 0 taken 1056060 times.
✓ Branch 1 taken 341183 times.
1397243 if(get_qr(qr_ENEMIESZAXIS))
8412 {
8413 341183 y=floor_y;
8414 341183 }
8415
8416
9/10
✓ Branch 0 taken 1282576 times.
✓ Branch 1 taken 114667 times.
✓ Branch 2 taken 1269012 times.
✓ Branch 3 taken 13564 times.
✓ Branch 4 taken 1269012 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 11176 times.
✓ Branch 7 taken 1257836 times.
✓ Branch 8 taken 11976 times.
✓ Branch 9 taken 21878 times.
1397243 if(clk>=0 && !stunclk && !frozenclock && (!watch || misc==0))
8417 {
8418
4/4
✓ Branch 0 taken 20260 times.
✓ Branch 1 taken 421148 times.
✓ Branch 2 taken 344884 times.
✓ Branch 3 taken 493422 times.
1279714 switch(misc)
8419 {
8420 case 0: // normal
8421
2/2
✓ Branch 0 taken 409927 times.
✓ Branch 1 taken 11221 times.
421148 if(!(zc_oldrand()%dmisc1))
8422 {
8423 11221 misc=1;
8424 11221 clk2=32;
8425 11221 }
8426
8427 421148 break;
8428
8429 case 1: // waiting to pounce
8430
2/2
✓ Branch 0 taken 324265 times.
✓ Branch 1 taken 20619 times.
344884 if(--clk2<=0)
8431 {
8432 20619 int32_t r=zc_oldrand();
8433 20619 misc=2;
8434 20619 step=0-(zslongToFix(dstep*100)); // initial speed
8435 20619 clk3=(r&1)+2; // left or right
8436 20619 clk2start=clk2=(r&31)+10; // flight time
8437
8438
2/2
✓ Branch 0 taken 18196 times.
✓ Branch 1 taken 2423 times.
20619 if(y<32) clk2+=2; // make them come down from top of screen
8439
8440
2/2
✓ Branch 0 taken 15702 times.
✓ Branch 1 taken 4917 times.
20619 if(y>112) clk2-=2; // make them go back up
8441
8442 20619 cstart=c = 9-((r&31)>>3); // time before gravity kicks in
8443 20619 }
8444
8445 344884 break;
8446
8447 case 2: // in flight
8448 493422 move(step);
8449
8450
2/2
✓ Branch 0 taken 234221 times.
✓ Branch 1 taken 259201 times.
493422 if(step>0) //going down
8451 {
8452
2/2
✓ Branch 0 taken 632 times.
✓ Branch 1 taken 233589 times.
234221 if(COMBOTYPE(x+8,y+16)==cNOJUMPZONE)
8453 {
8454 632 step=0-step;
8455 632 }
8456
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 233589 times.
233589 else if(COMBOTYPE(x+8,y+16)==cNOENEMY)
8457 {
8458 step=0-step;
8459 }
8460
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 233589 times.
233589 else if(ispitfall(x+8,y+16))
8461 {
8462 step=0-step;
8463 }
8464
2/2
✓ Branch 0 taken 47 times.
✓ Branch 1 taken 233542 times.
233589 else if(MAPFLAG(x+8,y+16)==mfNOENEMY)
8465 {
8466 47 step=0-step;
8467 47 }
8468
2/2
✓ Branch 0 taken 233531 times.
✓ Branch 1 taken 11 times.
233542 else if(MAPCOMBOFLAG(x+8,y+16)==mfNOENEMY)
8469 {
8470 11 step=0-step;
8471 11 }
8472 234221 }
8473
2/2
✓ Branch 0 taken 15154 times.
✓ Branch 1 taken 244047 times.
259201 else if(step<0)
8474 {
8475
2/2
✓ Branch 0 taken 438 times.
✓ Branch 1 taken 243609 times.
244047 if(COMBOTYPE(x+8,y)==cNOJUMPZONE)
8476 {
8477 438 step=0-step;
8478 438 }
8479
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 243609 times.
243609 else if(COMBOTYPE(x+8,y)==cNOENEMY)
8480 {
8481 step=0-step;
8482 }
8483
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 243609 times.
243609 else if(ispitfall(x+8,y))
8484 {
8485 step=0-step;
8486 }
8487
2/2
✓ Branch 0 taken 21 times.
✓ Branch 1 taken 243588 times.
243609 else if(MAPFLAG(x+8,y)==mfNOENEMY)
8488 {
8489 21 step=0-step;
8490 21 }
8491
2/2
✓ Branch 0 taken 243569 times.
✓ Branch 1 taken 19 times.
243588 else if(MAPCOMBOFLAG(x+8,y)==mfNOENEMY)
8492 {
8493 19 step=0-step;
8494 19 }
8495 244047 }
8496
8497
2/2
✓ Branch 0 taken 244152 times.
✓ Branch 1 taken 249270 times.
493422 if(clk3==left)
8498 {
8499
2/2
✓ Branch 0 taken 275 times.
✓ Branch 1 taken 243877 times.
244152 if(COMBOTYPE(x,y+8)==cNOJUMPZONE)
8500 {
8501 275 clk3^=1;
8502 275 }
8503
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 243871 times.
243877 else if(COMBOTYPE(x,y+8)==cNOENEMY)
8504 {
8505 6 clk3^=1;
8506 6 }
8507
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 243871 times.
243871 else if(ispitfall(x,y+8))
8508 {
8509 clk3^=1;
8510 }
8511
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 243841 times.
243871 else if(MAPFLAG(x,y+8)==mfNOENEMY)
8512 {
8513 30 clk3^=1;
8514 30 }
8515
2/2
✓ Branch 0 taken 243829 times.
✓ Branch 1 taken 12 times.
243841 else if(MAPCOMBOFLAG(x,y+8)==mfNOENEMY)
8516 {
8517 12 clk3^=1;
8518 12 }
8519 244152 }
8520 else
8521 {
8522
2/2
✓ Branch 0 taken 276 times.
✓ Branch 1 taken 248994 times.
249270 if(COMBOTYPE(x+16,y+8)==cNOJUMPZONE)
8523 {
8524 276 clk3^=1;
8525 276 }
8526
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 248982 times.
248994 else if(COMBOTYPE(x+16,y+8)==cNOENEMY)
8527 {
8528 12 clk3^=1;
8529 12 }
8530
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 248982 times.
248982 else if(ispitfall(x+16,y+8))
8531 {
8532 clk3^=1;
8533 }
8534
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 248977 times.
248982 else if(MAPFLAG(x+16,y+8)==mfNOENEMY)
8535 {
8536 5 clk3^=1;
8537 5 }
8538
2/2
✓ Branch 0 taken 248965 times.
✓ Branch 1 taken 12 times.
248977 else if(MAPCOMBOFLAG(x+16,y+8)==mfNOENEMY)
8539 {
8540 12 clk3^=1;
8541 12 }
8542 }
8543
8544 493422 --c;
8545
8546
4/4
✓ Branch 0 taken 151408 times.
✓ Branch 1 taken 342014 times.
✓ Branch 2 taken 320475 times.
✓ Branch 3 taken 172947 times.
493422 if(c<0 && step<zslongToFix(dstep*100))
8547 {
8548 172947 step+=zslongToFix(dmisc3*100);
8549 172947 }
8550
8551 493422 int32_t nb=get_qr(qr_NOBORDER) ? 16 : 0;
8552
8553
2/2
✓ Branch 0 taken 492701 times.
✓ Branch 1 taken 721 times.
493422 if(x<=16-nb) clk3=right;
8554
8555
2/2
✓ Branch 0 taken 492430 times.
✓ Branch 1 taken 992 times.
493422 if(x>=224+nb) clk3=left;
8556
8557 493422 x += (clk3==left) ? -1 : 1;
8558
8559
4/4
✓ Branch 0 taken 29025 times.
✓ Branch 1 taken 464397 times.
✓ Branch 2 taken 10130 times.
✓ Branch 3 taken 454267 times.
493422 if((--clk2<=0 && y>=16-nb) || y>=144+nb)
8560 {
8561
4/4
✓ Branch 0 taken 1621 times.
✓ Branch 1 taken 17274 times.
✓ Branch 2 taken 1436 times.
✓ Branch 3 taken 185 times.
39155 if(y>=144+nb && get_qr(qr_ENEMIESZAXIS))
8562 {
8563 185 step=0-step;
8564 185 y--;
8565 185 }
8566
2/2
✓ Branch 0 taken 5794 times.
✓ Branch 1 taken 12916 times.
18710 else if(zc_oldrand()%dmisc2) //land and wait
8567 {
8568 12916 clk=misc=0;
8569 12916 } //land and jump again
8570 else
8571 {
8572 5794 misc=1;
8573 5794 clk2=0;
8574 }
8575 18895 }
8576
8577 473162 break;
8578 } // switch
8579 1259454 }
8580
8581
4/4
✓ Branch 0 taken 341183 times.
✓ Branch 1 taken 1058478 times.
✓ Branch 2 taken 231206 times.
✓ Branch 3 taken 109977 times.
1399661 if(get_qr(qr_ENEMIESZAXIS) && misc==2)
8582 {
8583
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 109977 times.
109977 if (moveflags & move_use_fake_z)
8584 {
8585 int32_t tempy = floor_y;
8586 fakez=zc_max(0,zc_min(clk2start-clk2,clk2));
8587 floor_y = y;
8588 y=tempy-fakez;
8589 old_y = y;
8590 }
8591 else
8592 {
8593 109977 int32_t tempy = floor_y;
8594
6/6
✓ Branch 0 taken 55216 times.
✓ Branch 1 taken 54761 times.
✓ Branch 2 taken 104073 times.
✓ Branch 3 taken 5904 times.
✓ Branch 4 taken 50747 times.
✓ Branch 5 taken 53326 times.
109977 z=zc_max(0,zc_min(clk2start-clk2,clk2));
8595 109977 floor_y = y;
8596 109977 y=tempy-z;
8597 109977 old_y = y;
8598 }
8599 109977 }
8600
8601
4/4
✓ Branch 0 taken 13564 times.
✓ Branch 1 taken 1386097 times.
✓ Branch 2 taken 2927 times.
✓ Branch 3 taken 10637 times.
1399661 if(stunclk && (clk&31)==1)
8602 10637 clk=0;
8603
8604 1399661 return enemy::animate(index);
8605 1426328 }
8606
8607 803206 void eTektite::drawshadow(BITMAP *dest,bool translucent)
8608 {
8609
5/6
✓ Branch 0 taken 625928 times.
✓ Branch 1 taken 177278 times.
✓ Branch 2 taken 625928 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 600737 times.
✓ Branch 5 taken 25191 times.
803206 if(z<1 && fakez<1 && get_qr(qr_ENEMIESZAXIS))
8610 25191 return;
8611
8612 778015 int32_t tempy=yofs;
8613 778015 int32_t fdiv = frate/4;
8614
1/2
✓ Branch 0 taken 778015 times.
✗ Branch 1 not taken.
778015 int32_t efrate = fdiv == 0 ? 0 : clk/fdiv;
8615
1/2
✓ Branch 0 taken 778015 times.
✗ Branch 1 not taken.
778015 int32_t f2=get_qr(qr_NEWENEMYTILES)?
8616 778015 efrate:((clk>=(frate>>1))?1:0);
8617 778015 flip = 0;
8618 778015 shadowtile = wpnsbuf[spr_shadow].tile;
8619
8620
1/2
✓ Branch 0 taken 778015 times.
✗ Branch 1 not taken.
778015 if(get_qr(qr_NEWENEMYTILES))
8621 {
8622
2/2
✓ Branch 0 taken 575932 times.
✓ Branch 1 taken 202083 times.
778015 if(misc==0)
8623 {
8624 202083 shadowtile+=f2;
8625 202083 }
8626
2/2
✓ Branch 0 taken 254903 times.
✓ Branch 1 taken 321029 times.
575932 else if(misc!=1)
8627 321029 shadowtile+=2;
8628 778015 }
8629 else
8630 {
8631 if(misc==0)
8632 {
8633 shadowtile += f2 ? 1 : 0;
8634 }
8635 else if(misc!=1)
8636 {
8637 ++shadowtile;
8638 }
8639 }
8640
8641 778015 yofs+=8;
8642
8643
4/4
✓ Branch 0 taken 600737 times.
✓ Branch 1 taken 177278 times.
✓ Branch 2 taken 339908 times.
✓ Branch 3 taken 260829 times.
778015 if(!get_qr(qr_ENEMIESZAXIS) && misc==2)
8644 {
8645
6/6
✓ Branch 0 taken 134073 times.
✓ Branch 1 taken 126756 times.
✓ Branch 2 taken 243385 times.
✓ Branch 3 taken 17444 times.
✓ Branch 4 taken 123475 times.
✓ Branch 5 taken 119910 times.
260829 yofs+=zc_max(0,zc_min(clk2start-clk2,clk2));
8646 260829 }
8647
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 778015 times.
778015 if(!shadow_overpit(this))
8648 778015 enemy::drawshadow(dest,translucent);
8649 778015 yofs=tempy;
8650 803206 }
8651
8652 2045360 void eTektite::draw(BITMAP *dest)
8653 {
8654 2045360 update_enemy_frame();
8655 2045360 enemy::draw(dest);
8656 2045360 }
8657
8658 730 eItemFairy::eItemFairy(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
8659 730 {
8660
2/4
✓ Branch 0 taken 730 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 730 times.
✗ Branch 3 not taken.
730 step=zslongToFix(guysbuf[id&0xFFF].step*100);
8661 730 superman=1;
8662 730 dir=8;
8663 730 hxofs=1000;
8664 730 mainguy=false;
8665 730 count_enemy=false;
8666
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 730 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
730 if (SIZEflags != 0) init_size_flags();;
8667 730 }
8668
8669 279897 bool eItemFairy::animate(int32_t index)
8670 {
8671
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 279897 times.
279897 if(switch_hooked) return enemy::animate(index);
8672
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 279897 times.
279897 if(dying)
8673 return Dead(index);
8674
8675 //if(clk>32)
8676 279897 misc=1;
8677 279897 bool w=watch;
8678 279897 watch=false;
8679 279897 variable_walk_8(misc?3:0,0,8,spw_floater);
8680 279897 watch=w;
8681
8682
2/2
✓ Branch 0 taken 1514 times.
✓ Branch 1 taken 278383 times.
279897 if(clk==0)
8683 {
8684 1514 removearmos(x,y,ffcactivated);
8685 1514 }
8686
8687 279897 return enemy::animate(index);
8688 279897 }
8689
8690 562150 void eItemFairy::draw(BITMAP *dest)
8691 {
8692 //these are here to bypass compiler warnings about unused arguments
8693 562150 dest=dest;
8694 562150 }
8695
8696 1825 ePeahat::ePeahat(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
8697 1825 {
8698 //floater_walk(int32_t rate,int32_t newclk,zfix ms,zfix ss,int32_t s,int32_t p, int32_t g)
8699
10/20
✗ Branch 0 not taken.
✓ Branch 1 taken 1825 times.
✓ Branch 2 taken 1825 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1825 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1825 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1825 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 1825 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 1825 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 1825 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 1825 times.
✗ Branch 17 not taken.
✓ Branch 18 taken 1825 times.
✗ Branch 19 not taken.
1825 floater_walk(misc?rate:0, hrate, zslongToFix(dstep*100),zslongToFix(dstep*10), 10, dmisc16,dmisc17); // 80, 16);
8700 1825 dir=8;
8701 1825 movestatus=1;
8702 1825 clk=0;
8703
1/2
✓ Branch 0 taken 1825 times.
✗ Branch 1 not taken.
1825 step=0;
8704 //nets+720;
8705
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1825 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1825 if (SIZEflags != 0) init_size_flags();;
8706 1825 }
8707
8708 520615 bool ePeahat::animate(int32_t index)
8709 {
8710
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 520615 times.
520615 if(switch_hooked) return enemy::animate(index);
8711
2/4
✓ Branch 0 taken 520615 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 520615 times.
520615 if(fallclk||drownclk) return enemy::animate(index);
8712
2/2
✓ Branch 0 taken 78 times.
✓ Branch 1 taken 520537 times.
520615 if(slide())
8713 {
8714 78 return false;
8715 }
8716
8717
2/2
✓ Branch 0 taken 1030 times.
✓ Branch 1 taken 519507 times.
520537 if(dying)
8718 1030 return Dead(index);
8719
8720
2/2
✓ Branch 0 taken 3083 times.
✓ Branch 1 taken 516424 times.
519507 if(clk==0)
8721 {
8722 3083 removearmos(x,y,ffcactivated);
8723 3083 }
8724
8725
4/4
✓ Branch 0 taken 516389 times.
✓ Branch 1 taken 3118 times.
✓ Branch 2 taken 253336 times.
✓ Branch 3 taken 263053 times.
519507 if(stunclk==0 && clk>96)
8726 263053 misc=1;
8727
8728
2/2
✓ Branch 0 taken 2402 times.
✓ Branch 1 taken 517105 times.
519507 if(!watch)
8729
2/2
✓ Branch 0 taken 171491 times.
✓ Branch 1 taken 345614 times.
517105 floater_walk(misc?rate:0, hrate, zslongToFix(dstep*100),zslongToFix(dstep*10), 10, 80, 16);
8730
8731
3/4
✓ Branch 0 taken 100018 times.
✓ Branch 1 taken 419489 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 100018 times.
519507 if(get_qr(qr_ENEMIESZAXIS) && !(isSideViewGravity()))
8732 {
8733
1/2
✓ Branch 0 taken 100018 times.
✗ Branch 1 not taken.
100018 if (moveflags & move_use_fake_z) fakez=int32_t(step*1.1/((zslongToFix(dstep*10))*1.1));
8734 100018 else z=int32_t(step*1.1/((zslongToFix(dstep*10))*1.1));
8735 100018 }
8736
8737
4/4
✓ Branch 0 taken 2402 times.
✓ Branch 1 taken 517105 times.
✓ Branch 2 taken 768 times.
✓ Branch 3 taken 1634 times.
519507 if(watch && get_qr(qr_PEAHATCLOCKVULN))
8738 1634 superman=0;
8739 else
8740
2/2
✓ Branch 0 taken 9811 times.
✓ Branch 1 taken 508062 times.
517873 superman=(movestatus && !get_qr(qr_ENEMIESZAXIS)) ? 1 : 0;
8741 //stunclk=0; //Not sure what was going on here, or what was intended. Why was this set to 0? -Z
8742
2/2
✓ Branch 0 taken 264937 times.
✓ Branch 1 taken 254570 times.
519507 if ( FFCore.getQuestHeaderInfo(vZelda) >= 0x250 )
8743 {
8744
2/2
✓ Branch 0 taken 261822 times.
✓ Branch 1 taken 3115 times.
264937 if ( stunclk ) --stunclk;
8745 264937 }
8746 254570 else stunclk = 0; //Was probably this way in 2.10 quests. if not, then we never need to clear it. -Z
8747 //Pretty sure this was always an error. -Z ( 14FEB2019 )
8748
8749
8750
2/2
✓ Branch 0 taken 519267 times.
✓ Branch 1 taken 240 times.
519507 if(x<16) dir=right; //this is ugly, but so is moving or creating these guys with scripts.
8751
8752 519507 return enemy::animate(index);
8753 520615 }
8754
8755 334520 void ePeahat::drawshadow(BITMAP *dest, bool translucent)
8756 {
8757 334520 int32_t tempy=yofs;
8758 334520 flip = 0;
8759 334520 shadowtile = wpnsbuf[spr_shadow].tile+posframe;
8760
8761
2/2
✓ Branch 0 taken 88089 times.
✓ Branch 1 taken 246431 times.
334520 if(!get_qr(qr_ENEMIESZAXIS))
8762 {
8763 246431 yofs+=8;
8764 246431 yofs+=int32_t(step/zslongToFix(dstep*10));
8765 246431 }
8766
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 334520 times.
334520 if(!shadow_overpit(this))
8767 334520 enemy::drawshadow(dest,translucent);
8768 334520 yofs=tempy;
8769 334520 }
8770
8771 1144330 void ePeahat::draw(BITMAP *dest)
8772 {
8773 1144330 update_enemy_frame();
8774 1144330 enemy::draw(dest);
8775 1144330 }
8776
8777 4136 int32_t ePeahat::takehit(weapon *w, weapon* realweap)
8778 {
8779 4136 int32_t wpnId = w->id;
8780 4136 int32_t enemyHitWeapon = w->parentitem;
8781
8782
3/6
✓ Branch 0 taken 4136 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4136 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 4136 times.
4136 if(dying || clk<0 || hclk>0)
8783 return 0;
8784
8785
4/4
✓ Branch 0 taken 3381 times.
✓ Branch 1 taken 755 times.
✓ Branch 2 taken 38 times.
✓ Branch 3 taken 206 times.
4380 if(superman && !(wpnId==wSBomb) // vulnerable to super bombs
8786 // fire boomerang, for nailing peahats
8787
4/6
✓ Branch 0 taken 3381 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3137 times.
✓ Branch 3 taken 244 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 244 times.
3381 && !(wpnId==wBrang && (enemyHitWeapon>-1 ? itemsbuf[enemyHitWeapon].power : current_item_power(itype_brang))>0))
8788 3343 return 0;
8789
8790 // Time for a kludge...
8791 793 int32_t s = superman;
8792 793 superman = 0;
8793 793 int32_t ret = enemy::takehit(w,realweap);
8794 793 superman = s;
8795
8796 // Anyway...
8797
2/2
✓ Branch 0 taken 601 times.
✓ Branch 1 taken 192 times.
793 if(stunclk == 160)
8798 {
8799 192 clk2=0;
8800 192 movestatus=0;
8801 192 misc=0;
8802 192 clk=0;
8803 192 step=0;
8804 192 }
8805
8806 793 return ret;
8807 4136 }
8808
8809 // auomatically kill off enemy (for rooms with ringleaders)
8810 void ePeahat::kickbucket()
8811 {
8812 hp=-1000; // don't call death_sfx()
8813 }
8814
8815 3942 eLeever::eLeever(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
8816 3942 {
8817 // if(d->misc1==0) { misc=-1; clk-=16; } //Line of Sight leevers
8818
2/2
✓ Branch 0 taken 1795 times.
✓ Branch 1 taken 2147 times.
3942 if(dmisc1==0)
8819 {
8820 2147 misc=-1; //Line of Sight leevers
8821 2147 clk-=16;
8822 2147 }
8823 3942 clk3 = 0;
8824 //nets+1460;
8825 3942 temprule=(get_qr(qr_NEWENEMYTILES)) != 0;
8826 3942 submerged = false;
8827
1/4
✓ Branch 0 taken 3942 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3942 if (SIZEflags != 0) init_size_flags();;
8828 3942 }
8829
8830 923 bool eLeever::isSubmerged() const
8831 {
8832 923 Z_scripterrlog("misc is: %d\n", misc);
8833 923 return misc <= 0;
8834
8835 }
8836
8837 1018478 bool eLeever::animate(int32_t index)
8838 {
8839
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1018478 times.
1018478 if(switch_hooked) return enemy::animate(index);
8840
3/4
✓ Branch 0 taken 1018123 times.
✓ Branch 1 taken 355 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1018123 times.
1018478 if(fallclk||drownclk)
8841 {
8842 355 return enemy::animate(index);
8843 }
8844
2/2
✓ Branch 0 taken 31552 times.
✓ Branch 1 taken 986571 times.
1018123 if(dying)
8845 31552 return Dead(index);
8846
8847
2/2
✓ Branch 0 taken 941601 times.
✓ Branch 1 taken 44970 times.
986571 if(clk==0)
8848 {
8849 44970 removearmos(x,y,ffcactivated);
8850 44970 }
8851
8852
4/4
✓ Branch 0 taken 816947 times.
✓ Branch 1 taken 169624 times.
✓ Branch 2 taken 5265 times.
✓ Branch 3 taken 811682 times.
986571 if(clk>=0 && !slide())
8853 {
8854 // switch(d->misc1)
8855
2/2
✓ Branch 0 taken 337868 times.
✓ Branch 1 taken 473814 times.
811682 switch(dmisc1)
8856 {
8857 case 0: //line of sight
8858 case 2:
8859
7/8
✗ Branch 0 not taken.
✓ Branch 1 taken 124459 times.
✓ Branch 2 taken 49109 times.
✓ Branch 3 taken 35464 times.
✓ Branch 4 taken 15780 times.
✓ Branch 5 taken 101784 times.
✓ Branch 6 taken 4365 times.
✓ Branch 7 taken 6907 times.
337868 switch(misc) //is this leever active
8860 {
8861 case -1: //submerged
8862 {
8863
4/6
✓ Branch 0 taken 6382 times.
✓ Branch 1 taken 118077 times.
✓ Branch 2 taken 6382 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 6382 times.
124459 if (!get_qr(qr_LEEVERS_DONT_OBEY_STUN) && (watch || stunclk)) misc = 0;
8864
4/4
✓ Branch 0 taken 10299 times.
✓ Branch 1 taken 114160 times.
✓ Branch 2 taken 10261 times.
✓ Branch 3 taken 38 times.
124459 if((dmisc1==2)&&(zc_oldrand()&255))
8865 {
8866 10261 break;
8867 }
8868
8869 114198 int32_t active=0;
8870
8871
2/2
✓ Branch 0 taken 783342 times.
✓ Branch 1 taken 114198 times.
897540 for(int32_t i=0; i<guys.Count(); i++)
8872 {
8873
4/4
✓ Branch 0 taken 627294 times.
✓ Branch 1 taken 156048 times.
✓ Branch 2 taken 401598 times.
✓ Branch 3 taken 225696 times.
783342 if(guys.spr(i)->id==id && (((enemy*)guys.spr(i))->misc>=0))
8874 {
8875 225696 ++active;
8876 225696 }
8877 783342 }
8878
8879
2/2
✓ Branch 0 taken 112327 times.
✓ Branch 1 taken 1871 times.
114198 if(active<((dmisc1==2)?1:2))
8880 {
8881 1871 misc=0; //activate this one
8882 1871 clk3=1; //This needs to be set so that it knows that it's being emerged of its own will and not because it got stunned.
8883 1871 }
8884 }
8885 114198 break;
8886
8887 case 0:
8888 {
8889
8890
4/6
✓ Branch 0 taken 11920 times.
✓ Branch 1 taken 37189 times.
✓ Branch 2 taken 11920 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 11920 times.
49109 if (!get_qr(qr_LEEVERS_DONT_OBEY_STUN) && (watch || stunclk))
8891 {
8892 misc=1;
8893 clk2=0;
8894 }
8895
2/2
✓ Branch 0 taken 57 times.
✓ Branch 1 taken 49052 times.
49109 else if (clk3<=0)
8896 {
8897 57 misc = -1;
8898 57 break;
8899 }
8900 49052 int32_t s=0;
8901
8902
2/2
✓ Branch 0 taken 273250 times.
✓ Branch 1 taken 49052 times.
322302 for(int32_t i=0; i<guys.Count(); i++)
8903 {
8904
4/4
✓ Branch 0 taken 164314 times.
✓ Branch 1 taken 108936 times.
✓ Branch 2 taken 156432 times.
✓ Branch 3 taken 7882 times.
273250 if(guys.spr(i)->id==id && ((enemy*)guys.spr(i))->misc==1)
8905 {
8906 7882 ++s;
8907 7882 }
8908 273250 }
8909
8910
2/2
✓ Branch 0 taken 7882 times.
✓ Branch 1 taken 41170 times.
49052 if(s>0)
8911 {
8912 7882 break;
8913 }
8914
8915 41170 int32_t d2=zc_oldrand()&1;
8916
8917
2/2
✓ Branch 0 taken 14509 times.
✓ Branch 1 taken 26661 times.
41170 if(HeroDir()>=left)
8918 {
8919 26661 d2+=2;
8920 26661 }
8921
8922
4/4
✓ Branch 0 taken 39722 times.
✓ Branch 1 taken 1448 times.
✓ Branch 2 taken 662 times.
✓ Branch 3 taken 39060 times.
41170 if(canplace(d2) || canplace(d2^1))
8923 {
8924 2110 misc=1;
8925 2110 clk2=0;
8926 2110 clk=0;
8927 2110 }
8928 }
8929 41170 break;
8930
8931 case 1:
8932
8933
7/8
✓ Branch 0 taken 33397 times.
✓ Branch 1 taken 2067 times.
✓ Branch 2 taken 3596 times.
✓ Branch 3 taken 29801 times.
✓ Branch 4 taken 3596 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1 times.
✓ Branch 7 taken 3595 times.
35464 if(++clk2>16||(!get_qr(qr_LEEVERS_DONT_OBEY_STUN) && (watch || stunclk) && clk2>8)) misc=2;
8934
8935 35464 break;
8936
8937 case 2:
8938
8939
7/8
✓ Branch 0 taken 13865 times.
✓ Branch 1 taken 1915 times.
✓ Branch 2 taken 1503 times.
✓ Branch 3 taken 12362 times.
✓ Branch 4 taken 1503 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1 times.
✓ Branch 7 taken 1502 times.
15780 if(++clk2>24||(!get_qr(qr_LEEVERS_DONT_OBEY_STUN) && (watch || stunclk) && clk2>12)) misc=3;
8940
8941 15780 break;
8942
8943 // case 3: if(stunclk) break; if(scored) dir^=1; if(!canmove(dir,false)) misc=4; else move((zfix)(d->step/100.0)); break;
8944 case 3:
8945
8946
5/6
✓ Branch 0 taken 98195 times.
✓ Branch 1 taken 3589 times.
✓ Branch 2 taken 98195 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2727 times.
✓ Branch 5 taken 95468 times.
101784 if(stunclk || frozenclock || watch) break;
8947
8948
2/2
✓ Branch 0 taken 142 times.
✓ Branch 1 taken 95326 times.
95468 if(scored) dir^=1;
8949
8950
2/2
✓ Branch 0 taken 505 times.
✓ Branch 1 taken 94963 times.
95468 if(!canmove(dir,false)) misc=4;
8951 94963 else move(zslongToFix(dstep*100));
8952
8953 95468 break;
8954
8955 case 4:
8956
4/6
✓ Branch 0 taken 610 times.
✓ Branch 1 taken 3755 times.
✓ Branch 2 taken 610 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 610 times.
4365 if (!get_qr(qr_LEEVERS_DONT_OBEY_STUN) && (watch || stunclk)) misc = 2;
8957
2/2
✓ Branch 0 taken 3897 times.
✓ Branch 1 taken 468 times.
4365 if(--clk2<=16)
8958 {
8959 468 misc=5;
8960 468 clk=8;
8961 468 }
8962
8963 4365 break;
8964
8965 case 5:
8966
5/6
✓ Branch 0 taken 1010 times.
✓ Branch 1 taken 5897 times.
✓ Branch 2 taken 1010 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✓ Branch 5 taken 1009 times.
6907 if (!get_qr(qr_LEEVERS_DONT_OBEY_STUN) && (watch || stunclk)) misc = 1;
8967
2/2
✓ Branch 0 taken 6497 times.
✓ Branch 1 taken 410 times.
6907 if(--clk2<=0) misc=((dmisc1==2)?-1:0);
8968
8969 6907 break;
8970 } // switch(misc)
8971
8972 337868 break;
8973
8974 default: //random
8975 // step=d->misc3/100.0;
8976
8977 473814 step=zslongToFix(dmisc3*100);
8978
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 473814 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
473814 if (get_qr(qr_LEEVERS_DONT_OBEY_STUN) || (!watch && !stunclk)) ++clk2;
8979 else if (!get_qr(qr_LEEVERS_DONT_OBEY_STUN) && (watch || stunclk))
8980 {
8981 if (clk2 < 48) clk2+=2;
8982 if (clk2 >= 300) clk2-=2;
8983 }
8984
8985
2/2
✓ Branch 0 taken 60840 times.
✓ Branch 1 taken 412974 times.
473814 if(clk2<32) misc=1;
8986
2/2
✓ Branch 0 taken 30244 times.
✓ Branch 1 taken 382730 times.
412974 else if(clk2<48) misc=2;
8987
2/2
✓ Branch 0 taken 289541 times.
✓ Branch 1 taken 93189 times.
382730 else if(clk2<300)
8988 {
8989 /*if(misc==2 && (int32_t)(dmisc3*0.48)%8)
8990 {
8991 fix_coords();
8992 }*/
8993 289541 misc=3;
8994 289541 step = zslongToFix(dstep*100);
8995 289541 }
8996
2/2
✓ Branch 0 taken 9009 times.
✓ Branch 1 taken 84180 times.
93189 else if(clk2<316) misc=2;
8997
2/2
✓ Branch 0 taken 43755 times.
✓ Branch 1 taken 40425 times.
84180 else if(clk2<412) misc=1;
8998
2/2
✓ Branch 0 taken 40151 times.
✓ Branch 1 taken 274 times.
40425 else if(clk2<540)
8999 {
9000 40151 misc=0;
9001 40151 step=0;
9002 40151 }
9003 274 else clk2=0;
9004
9005
2/2
✓ Branch 0 taken 471961 times.
✓ Branch 1 taken 1853 times.
473814 if(clk2==48) clk=0;
9006
9007 // variable_walk(d->rate, d->homing, 0);
9008 473814 variable_walk(rate, homing, 0);
9009 473814 } // switch(dmisc1)
9010 811682 }
9011
9012 986571 hxofs=(misc>=2)?0:1000;
9013 986571 return enemy::animate(index);
9014 1018478 }
9015
9016 80892 bool eLeever::canplace(int32_t d2)
9017 {
9018 80892 int32_t nx=HeroX();
9019 80892 int32_t ny=HeroY();
9020
9021
2/2
✓ Branch 0 taken 28492 times.
✓ Branch 1 taken 52400 times.
80892 if(d2<left) ny&=0xF0;
9022 52400 else nx&=0xF0;
9023
9024
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 14174 times.
✓ Branch 2 taken 14318 times.
✓ Branch 3 taken 26181 times.
✓ Branch 4 taken 26219 times.
80892 switch(d2)
9025 {
9026 // case up: ny-=((d->misc1==0)?32:48); break;
9027 // case down: ny+=((d->misc1==0)?32:48); if(ny-HeroY()<32) ny+=((d->misc1==0)?16:0); break;
9028 // case left: nx-=((d->misc1==0)?32:48); break;
9029 // case right: nx+=((d->misc1==0)?32:48); if(nx-HeroX()<32) nx+=((d->misc1==0)?16:0); break;
9030 case up:
9031
2/2
✓ Branch 0 taken 14144 times.
✓ Branch 1 taken 30 times.
14174 ny-=((dmisc1==0||dmisc1==2)?32:48);
9032 14174 break;
9033
9034 case down:
9035
2/2
✓ Branch 0 taken 34 times.
✓ Branch 1 taken 14284 times.
14318 ny+=((dmisc1==0||dmisc1==2)?32:48);
9036
9037
4/4
✓ Branch 0 taken 10086 times.
✓ Branch 1 taken 4232 times.
✓ Branch 2 taken 10075 times.
✓ Branch 3 taken 11 times.
14318 if(ny-HeroY()<32) ny+=((dmisc1==0||dmisc1==2)?16:0);
9038
9039 14318 break;
9040
9041 case left:
9042
2/2
✓ Branch 0 taken 25528 times.
✓ Branch 1 taken 653 times.
26181 nx-=((dmisc1==0||dmisc1==2)?32:48);
9043 26181 break;
9044
9045 case right:
9046
2/2
✓ Branch 0 taken 646 times.
✓ Branch 1 taken 25573 times.
26219 nx+=((dmisc1==0||dmisc1==2)?32:48);
9047
9048
4/4
✓ Branch 0 taken 19151 times.
✓ Branch 1 taken 7068 times.
✓ Branch 2 taken 18549 times.
✓ Branch 3 taken 602 times.
26219 if(nx-HeroX()<32) nx+=((dmisc1==0||dmisc1==2)?16:0);
9049
9050 26219 break;
9051 }
9052
9053
4/4
✓ Branch 0 taken 20428 times.
✓ Branch 1 taken 60464 times.
✓ Branch 2 taken 9001 times.
✓ Branch 3 taken 11427 times.
80892 if(m_walkflag(nx,ny,spw_halfstep, dir)||m_walkflag(nx,ny-8,spw_halfstep, dir)) /*none*/
9054 69465 return false;
9055
9056
2/2
✓ Branch 0 taken 864 times.
✓ Branch 1 taken 10563 times.
11427 if(d2>=left)
9057
4/4
✓ Branch 0 taken 5025 times.
✓ Branch 1 taken 5538 times.
✓ Branch 2 taken 9317 times.
✓ Branch 3 taken 1246 times.
10563 if(m_walkflag(HeroX(),HeroY(),spw_halfstep, dir)||m_walkflag(HeroX(),HeroY()-8,spw_halfstep, dir)) /*none*/
9058 9317 return false;
9059
9060 2110 x=nx;
9061 2110 y=ny;
9062 2110 dir=d2^1;
9063 2110 return true;
9064 80892 }
9065
9066 1024382 void eLeever::draw(BITMAP *dest)
9067 {
9068 // cs=d->cset;
9069 1024382 cs=dcset;
9070 1024382 update_enemy_frame();
9071
3/4
✓ Branch 0 taken 1024027 times.
✓ Branch 1 taken 355 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1024027 times.
1024382 if(!fallclk&&!drownclk)
9072 {
9073
2/2
✓ Branch 0 taken 637088 times.
✓ Branch 1 taken 386939 times.
1024027 switch(misc)
9074 {
9075 case -1:
9076 case 0:
9077 386939 return;
9078 }
9079 637088 }
9080
9081 637443 enemy::draw(dest);
9082 1024382 }
9083
9084 998 eWallM::eWallM(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
9085 998 {
9086 998 hashero=false;
9087 //nets+1000;
9088
1/4
✓ Branch 0 taken 998 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
998 if (SIZEflags != 0) init_size_flags();;
9089 998 }
9090
9091 504762 bool eWallM::animate(int32_t index)
9092 {
9093
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 504762 times.
504762 if(switch_hooked) return enemy::animate(index);
9094
2/4
✓ Branch 0 taken 504762 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 504762 times.
504762 if(fallclk||drownclk)
9095 {
9096 return enemy::animate(index);
9097 }
9098
2/2
✓ Branch 0 taken 9856 times.
✓ Branch 1 taken 494906 times.
504762 if(dying)
9099 9856 return Dead(index);
9100
9101
2/2
✓ Branch 0 taken 463930 times.
✓ Branch 1 taken 30976 times.
494906 if(clk==0)
9102 {
9103 30976 removearmos(x,y,ffcactivated);
9104 30976 }
9105
9106 494906 hxofs=1000;
9107
2/2
✓ Branch 0 taken 117732 times.
✓ Branch 1 taken 377174 times.
494906 if(misc==0) //inside wall, ready to spawn?
9108 {
9109
4/4
✓ Branch 0 taken 228512 times.
✓ Branch 1 taken 148662 times.
✓ Branch 2 taken 16723 times.
✓ Branch 3 taken 211789 times.
377174 if(frame-wallm_load_clk>80 && clk>=0)
9110 {
9111 211789 int32_t wall=hero_on_wall();
9112 211789 int32_t wallm_cnt=0;
9113
9114
2/2
✓ Branch 0 taken 1670618 times.
✓ Branch 1 taken 211789 times.
1882407 for(int32_t i=0; i<guys.Count(); i++)
9115
2/2
✓ Branch 0 taken 657527 times.
✓ Branch 1 taken 1013091 times.
2683709 if(((enemy*)guys.spr(i))->family==eeWALLM)
9116 {
9117 1013091 int32_t m=((enemy*)guys.spr(i))->misc;
9118
9119
4/4
✓ Branch 0 taken 50104 times.
✓ Branch 1 taken 962987 times.
✓ Branch 2 taken 36738 times.
✓ Branch 3 taken 13366 times.
1013091 if(m && ((enemy*)guys.spr(i))->clk3==(wall^1))
9120 {
9121 13366 ++wallm_cnt;
9122 13366 }
9123 1013091 }
9124
9125
2/2
✓ Branch 0 taken 210948 times.
✓ Branch 1 taken 841 times.
211789 if(wall>0)
9126 {
9127 841 --wall;
9128 841 misc=1; //emerging from the wall?
9129 841 clk2=0;
9130 841 clk3=wall^1;
9131 841 wallm_load_clk=frame;
9132
9133
2/2
✓ Branch 0 taken 514 times.
✓ Branch 1 taken 327 times.
841 if(wall<=down)
9134 {
9135
2/2
✓ Branch 0 taken 91 times.
✓ Branch 1 taken 423 times.
514 if(HeroDir()==left)
9136 91 dir=right;
9137 else
9138 423 dir=left;
9139 514 }
9140 else
9141 {
9142
2/2
✓ Branch 0 taken 66 times.
✓ Branch 1 taken 261 times.
327 if(HeroDir()==up)
9143 66 dir=down;
9144 else
9145 261 dir=up;
9146 }
9147
9148
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 231 times.
✓ Branch 2 taken 283 times.
✓ Branch 3 taken 223 times.
✓ Branch 4 taken 104 times.
841 switch(wall)
9149 {
9150 case up:
9151 231 y=0;
9152 231 break;
9153
9154 case down:
9155 283 y=160;
9156 283 break;
9157
9158 case left:
9159 223 x=0;
9160 223 break;
9161
9162 case right:
9163 104 x=240;
9164 104 break;
9165 }
9166
9167
9168
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 261 times.
✓ Branch 2 taken 66 times.
✓ Branch 3 taken 423 times.
✓ Branch 4 taken 91 times.
841 switch(dir)
9169 {
9170 case up:
9171 261 y=(HeroY()+48-(wallm_cnt&1)*12);
9172 261 flip=wall&1;
9173 261 break;
9174
9175 case down:
9176 66 y=(HeroY()-48+(wallm_cnt&1)*12);
9177 66 flip=((wall&1)^1)+2;
9178 66 break;
9179
9180 case left:
9181 423 x=(HeroX()+48-(wallm_cnt&1)*12);
9182 423 flip=(wall==up?2:0)+1;
9183 423 break;
9184
9185 case right:
9186 91 x=(HeroX()-48+(wallm_cnt&1)*12);
9187 91 flip=(wall==up?2:0);
9188 91 break;
9189 }
9190
9191 841 }
9192 211789 }
9193 377174 }
9194 else
9195 117732 wallm_crawl();
9196
9197 494906 return enemy::animate(index);
9198 504762 }
9199
9200 117732 void eWallM::wallm_crawl()
9201 {
9202 117732 bool w=watch;
9203 117732 hxofs=0;
9204
9205
2/2
✓ Branch 0 taken 810 times.
✓ Branch 1 taken 116922 times.
117732 if(slide())
9206 {
9207 810 return;
9208 }
9209
9210 // if(dying || watch || (!hashero && stunclk))
9211
6/8
✓ Branch 0 taken 116922 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 115593 times.
✓ Branch 3 taken 1329 times.
✓ Branch 4 taken 101047 times.
✓ Branch 5 taken 14546 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 101047 times.
116922 if(dying || (!hashero && ( stunclk || frozenclock )))
9212 {
9213 14546 return;
9214 }
9215
9216 102376 watch=false;
9217 102376 ++clk2;
9218 // Misc1: slightly different movement
9219 102376 float tmpmisc3 = ((40.0/(int32_t)dstep)*40);
9220
9221 //int32_t tmpmisc = int32_t((40.0/dstep)*40);
9222
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 102376 times.
102376 misc=(clk2/(dmisc1==1?40:(int32_t)tmpmisc3))+1;
9223
5/6
✓ Branch 0 taken 6217 times.
✓ Branch 1 taken 96159 times.
✓ Branch 2 taken 4491 times.
✓ Branch 3 taken 1726 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 4491 times.
102376 if(w&&misc>=3&&misc<=5)
9224 {
9225 4491 --clk2;
9226 4491 }
9227
9228
4/4
✓ Branch 0 taken 39396 times.
✓ Branch 1 taken 52852 times.
✓ Branch 2 taken 9984 times.
✓ Branch 3 taken 144 times.
102376 switch(misc)
9229 {
9230 case 1:
9231 case 2:
9232 52852 zc_swap(dir,clk3);
9233 52852 move(step);
9234 52852 zc_swap(dir,clk3);
9235 52852 break;
9236
9237 case 3:
9238 case 4:
9239 case 5:
9240
2/2
✓ Branch 0 taken 4491 times.
✓ Branch 1 taken 34905 times.
39396 if(w)
9241 {
9242 4491 watch=w;
9243 4491 return;
9244 }
9245
9246 34905 move(step);
9247 34905 break;
9248
9249 case 6:
9250 case 7:
9251 9984 zc_swap(dir,clk3);
9252 9984 dir^=1;
9253 9984 move(step);
9254 9984 dir^=1;
9255 9984 zc_swap(dir,clk3);
9256 9984 break;
9257
9258 default:
9259 144 misc=0;
9260 144 break;
9261 }
9262
9263 97885 watch=w;
9264 117732 }
9265
9266 9 void eWallM::grabhero()
9267 {
9268 9 hashero=true;
9269 9 superman=1;
9270 9 }
9271
9272 507147 void eWallM::draw(BITMAP *dest)
9273 {
9274 507147 dummy_bool[1]=hashero;
9275 507147 update_enemy_frame();
9276
9277
4/6
✓ Branch 0 taken 377966 times.
✓ Branch 1 taken 129181 times.
✓ Branch 2 taken 377966 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 377966 times.
507147 if(misc>0 || fallclk||drownclk)
9278 {
9279 129181 masked_draw(dest,16,playing_field_offset+16,224,144);
9280 129181 }
9281
9282 // enemy::draw(dest);
9283 // tile = clk&8 ? 128:129;
9284 507147 }
9285
9286 bool eWallM::isSubmerged() const
9287 {
9288 return ( !misc );
9289 }
9290
9291 1600 eTrap::eTrap(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
9292 1600 {
9293
1/2
✓ Branch 0 taken 1600 times.
✗ Branch 1 not taken.
1600 ox=x; //original x
9294
1/2
✓ Branch 0 taken 1600 times.
✗ Branch 1 not taken.
1600 oy=y; //original y
9295
2/2
✓ Branch 0 taken 1474 times.
✓ Branch 1 taken 126 times.
1600 if(get_qr(qr_TRAPPOSFIX))
9296 {
9297
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 126 times.
✓ Branch 2 taken 126 times.
✗ Branch 3 not taken.
126 yofs = (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
9298 126 }
9299
9300 1600 mainguy=false;
9301
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1600 times.
1600 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
9302 //nets+420;
9303 1600 dummy_int[1]=0;
9304
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1600 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1600 if (SIZEflags != 0) init_size_flags();;
9305 1600 }
9306
9307 1036935 bool eTrap::animate(int32_t index)
9308 {
9309
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1036935 times.
1036935 if(switch_hooked) return enemy::animate(index);
9310
2/4
✓ Branch 0 taken 1036935 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1036935 times.
1036935 if(fallclk||drownclk) return enemy::animate(index);
9311
2/2
✓ Branch 0 taken 1015341 times.
✓ Branch 1 taken 21594 times.
1036935 if(clk<0)
9312 21594 return enemy::animate(index);
9313
9314
2/2
✓ Branch 0 taken 951124 times.
✓ Branch 1 taken 64217 times.
1015341 if(clk==0)
9315 {
9316 64217 removearmos(x,y,ffcactivated);
9317 64217 }
9318
9319
2/2
✓ Branch 0 taken 317997 times.
✓ Branch 1 taken 697344 times.
1015341 if(misc==0) // waiting
9320 {
9321 697344 ox = x;
9322 697344 oy = y;
9323 double _MSVC2022_tmp1, _MSVC2022_tmp2;
9324 697344 double ddir=atan2_MSVC2022_FIX(double(y-(Hero.y)),double(Hero.x-x));
9325
9326
4/4
✓ Branch 0 taken 240663 times.
✓ Branch 1 taken 456681 times.
✓ Branch 2 taken 133176 times.
✓ Branch 3 taken 107487 times.
697344 if((ddir<=(((-1)*PI)/4))&&(ddir>(((-3)*PI)/4)))
9327 {
9328 107487 dir=down;
9329 107487 }
9330
4/4
✓ Branch 0 taken 391518 times.
✓ Branch 1 taken 198339 times.
✓ Branch 2 taken 133176 times.
✓ Branch 3 taken 258342 times.
589857 else if((ddir<=(((1)*PI)/4))&&(ddir>(((-1)*PI)/4)))
9331 {
9332 258342 dir=right;
9333 258342 }
9334
4/4
✓ Branch 0 taken 210645 times.
✓ Branch 1 taken 120870 times.
✓ Branch 2 taken 133176 times.
✓ Branch 3 taken 77469 times.
331515 else if((ddir<=(((3)*PI)/4))&&(ddir>(((1)*PI)/4)))
9335 {
9336 77469 dir=up;
9337 77469 }
9338 else
9339 {
9340 254046 dir=left;
9341 }
9342
9343 697344 int32_t d2=lined_up(15,true);
9344
9345
4/4
✓ Branch 0 taken 267045 times.
✓ Branch 1 taken 430299 times.
✓ Branch 2 taken 1111152 times.
✓ Branch 3 taken 413808 times.
1091329 if(((d2<left || d2 > right) && (dmisc1==1)) ||
9346
2/2
✓ Branch 0 taken 232556 times.
✓ Branch 1 taken 190596 times.
413808 ((d2>down) && (dmisc1==2)) ||
9347
2/2
✓ Branch 0 taken 187069 times.
✓ Branch 1 taken 60611 times.
190596 ((d2>right) && (!dmisc1)) ||
9348
2/2
✓ Branch 0 taken 393985 times.
✓ Branch 1 taken 146305 times.
247680 ((d2<l_up) && (dmisc1==4)) ||
9349
3/4
✓ Branch 0 taken 393985 times.
✓ Branch 1 taken 247680 times.
✓ Branch 2 taken 393985 times.
✗ Branch 3 not taken.
146305 ((d2!=r_up) && (d2!=l_down) && (dmisc1==6)) ||
9350
3/4
✓ Branch 0 taken 393985 times.
✓ Branch 1 taken 146305 times.
✓ Branch 2 taken 393985 times.
✗ Branch 3 not taken.
247680 ((d2!=l_up) && (d2!=r_down) && (dmisc1==8)))
9351 {
9352 2525663 d2=-1;
9353 2525663 }
9354
9355
4/4
✓ Branch 0 taken 20700 times.
✓ Branch 1 taken 428964 times.
✓ Branch 2 taken 18593 times.
✓ Branch 3 taken 2107 times.
449664 if(d2!=-1 && trapmove(d2))
9356 {
9357 2107 dir=d2;
9358 2107 misc=1;
9359 2107 clk2=(dir==down)?3:0;
9360 2107 }
9361 449664 }
9362
9363
2/2
✓ Branch 0 taken 678404 times.
✓ Branch 1 taken 89257 times.
767661 if(misc==1) // charging
9364 {
9365 89257 clk2=(clk2+1)&3;
9366 89257 step=(clk2==3)?1:2;
9367
9368
4/4
✓ Branch 0 taken 88461 times.
✓ Branch 1 taken 796 times.
✓ Branch 2 taken 1105 times.
✓ Branch 3 taken 87356 times.
89257 if(!trapmove(dir) || clip())
9369 {
9370 1901 misc=2;
9371
9372
1/2
✓ Branch 0 taken 1901 times.
✗ Branch 1 not taken.
1901 if(dir<l_up)
9373 {
9374 1901 dir=dir^1;
9375 1901 }
9376 else
9377 {
9378 dir=dir^3;
9379 }
9380 1901 }
9381 else
9382 {
9383 87356 sprite::move(step);
9384 }
9385 89257 }
9386
9387
2/2
✓ Branch 0 taken 534913 times.
✓ Branch 1 taken 232748 times.
767661 if(misc==2) // retreating
9388 {
9389 232748 step=(++clk2&1)?1:0;
9390
9391
4/9
✗ Branch 0 not taken.
✓ Branch 1 taken 39011 times.
✓ Branch 2 taken 80505 times.
✓ Branch 3 taken 29129 times.
✓ Branch 4 taken 84103 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
232748 switch(dir)
9392 {
9393 case up:
9394
2/2
✓ Branch 0 taken 272 times.
✓ Branch 1 taken 38739 times.
39011 if(int32_t(y)<=oy) goto trap_rest;
9395 38739 else sprite::move(step);
9396
9397 38739 break;
9398
9399 case left:
9400
2/2
✓ Branch 0 taken 388 times.
✓ Branch 1 taken 80117 times.
80505 if(int32_t(x)<=ox) goto trap_rest;
9401 80117 else sprite::move(step);
9402
9403 80117 break;
9404
9405 case down:
9406
2/2
✓ Branch 0 taken 224 times.
✓ Branch 1 taken 28905 times.
29129 if(int32_t(y)>=oy) goto trap_rest;
9407 28905 else sprite::move(step);
9408
9409 28905 break;
9410
9411 case right:
9412
2/2
✓ Branch 0 taken 431 times.
✓ Branch 1 taken 83672 times.
84103 if(int32_t(x)>=ox) goto trap_rest;
9413 83672 else sprite::move(step);
9414
9415 83672 break;
9416
9417 case l_up:
9418 if(int32_t(x)<=ox && int32_t(y)<=oy) goto trap_rest;
9419 else sprite::move(step);
9420
9421 break;
9422
9423 case r_up:
9424 if(int32_t(x)>=ox && int32_t(y)<=oy) goto trap_rest;
9425 else sprite::move(step);
9426
9427 break;
9428
9429 case l_down:
9430 if(int32_t(x)<=ox && int32_t(y)>=oy) goto trap_rest;
9431 else sprite::move(step);
9432
9433 break;
9434
9435 case r_down:
9436 if(int32_t(x)>=ox && int32_t(y)>=oy) goto trap_rest;
9437 else sprite::move(step);
9438
9439 break;
9440 trap_rest:
9441 {
9442 1315 x=ox;
9443 1315 y=oy;
9444 1315 misc=0;
9445 }
9446 1315 }
9447 232748 }
9448
9449 767661 return enemy::animate(index);
9450 789255 }
9451
9452 109957 bool eTrap::trapmove(int32_t ndir)
9453 {
9454
2/2
✓ Branch 0 taken 80193 times.
✓ Branch 1 taken 29764 times.
109957 if(get_qr(qr_MEANTRAPS))
9455 {
9456
2/2
✓ Branch 0 taken 1340 times.
✓ Branch 1 taken 78853 times.
80193 if(tmpscr->flags2&fFLOATTRAPS)
9457 1340 return canmove(ndir,(zfix)1,spw_floater, 0, 0, 15, 15,false);
9458
9459 78853 return canmove(ndir,(zfix)1,spw_water, 0, 0, 15, 15,false);
9460 }
9461
9462
6/6
✓ Branch 0 taken 14672 times.
✓ Branch 1 taken 15092 times.
✓ Branch 2 taken 7198 times.
✓ Branch 3 taken 7474 times.
✓ Branch 4 taken 2468 times.
✓ Branch 5 taken 4730 times.
29764 if(oy==80 && !(ndir==left || ndir == right))
9463 4730 return false;
9464
9465
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 25034 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
25034 if(ox==128 && !(ndir==up || ndir==down))
9466 return false;
9467
9468
3/4
✓ Branch 0 taken 7496 times.
✓ Branch 1 taken 17538 times.
✓ Branch 2 taken 7496 times.
✗ Branch 3 not taken.
25034 if(oy<80 && ndir==up)
9469 return false;
9470
9471
3/4
✓ Branch 0 taken 7596 times.
✓ Branch 1 taken 17438 times.
✓ Branch 2 taken 7596 times.
✗ Branch 3 not taken.
25034 if(oy>80 && ndir==down)
9472 return false;
9473
9474
4/4
✓ Branch 0 taken 14455 times.
✓ Branch 1 taken 10579 times.
✓ Branch 2 taken 9733 times.
✓ Branch 3 taken 4722 times.
25034 if(ox<128 && ndir==left)
9475 4722 return false;
9476
9477
4/4
✓ Branch 0 taken 10579 times.
✓ Branch 1 taken 9733 times.
✓ Branch 2 taken 9866 times.
✓ Branch 3 taken 713 times.
20312 if(ox>128 && ndir==right)
9478 713 return false;
9479
9480
5/6
✓ Branch 0 taken 9733 times.
✓ Branch 1 taken 9866 times.
✓ Branch 2 taken 4067 times.
✓ Branch 3 taken 5666 times.
✓ Branch 4 taken 4067 times.
✗ Branch 5 not taken.
19599 if(ox<128 && oy<80 && ndir==l_up)
9481 return false;
9482
9483
5/6
✓ Branch 0 taken 9733 times.
✓ Branch 1 taken 9866 times.
✓ Branch 2 taken 3911 times.
✓ Branch 3 taken 5822 times.
✓ Branch 4 taken 3911 times.
✗ Branch 5 not taken.
19599 if(ox<128 && oy>80 && ndir==l_down)
9484 return false;
9485
9486
5/6
✓ Branch 0 taken 9866 times.
✓ Branch 1 taken 9733 times.
✓ Branch 2 taken 3429 times.
✓ Branch 3 taken 6437 times.
✓ Branch 4 taken 3429 times.
✗ Branch 5 not taken.
19599 if(ox>128 && oy<80 && ndir==r_up)
9487 return false;
9488
9489
5/6
✓ Branch 0 taken 9866 times.
✓ Branch 1 taken 9733 times.
✓ Branch 2 taken 3685 times.
✓ Branch 3 taken 6181 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 3685 times.
19599 if(ox>128 && oy>80 && ndir==r_down)
9490 return false;
9491
9492 19599 return true;
9493 109957 }
9494
9495 88461 bool eTrap::clip()
9496 {
9497
2/2
✓ Branch 0 taken 43022 times.
✓ Branch 1 taken 45439 times.
88461 if(get_qr(qr_MEANPLACEDTRAPS))
9498 {
9499
4/9
✗ Branch 0 not taken.
✓ Branch 1 taken 5792 times.
✓ Branch 2 taken 8656 times.
✓ Branch 3 taken 15895 times.
✓ Branch 4 taken 15096 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
45439 switch(dir)
9500 {
9501 case up:
9502
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5792 times.
5792 if(y<=0) return true;
9503
9504 5792 break;
9505
9506 case down:
9507
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8656 times.
8656 if(y>=160) return true;
9508
9509 8656 break;
9510
9511 case left:
9512
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15895 times.
15895 if(x<=0) return true;
9513
9514 15895 break;
9515
9516 case right:
9517
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15096 times.
15096 if(x>=240) return true;
9518
9519 15096 break;
9520
9521 case l_up:
9522 if(y<=0||x<=0) return true;
9523
9524 break;
9525
9526 case l_down:
9527 if(y>=160||x<=0) return true;
9528
9529 break;
9530
9531 case r_up:
9532 if(y<=0||x>=240) return true;
9533
9534 break;
9535
9536 case r_down:
9537 if(y>=160||x>=240) return true;
9538
9539 break;
9540 }
9541
9542 45439 return false;
9543 }
9544 else
9545 {
9546
4/9
✗ Branch 0 not taken.
✓ Branch 1 taken 4882 times.
✓ Branch 2 taken 5449 times.
✓ Branch 3 taken 16755 times.
✓ Branch 4 taken 15936 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
43022 switch(dir)
9547 {
9548 case up:
9549
4/4
✓ Branch 0 taken 4828 times.
✓ Branch 1 taken 54 times.
✓ Branch 2 taken 4641 times.
✓ Branch 3 taken 187 times.
4882 if(oy>80 && y<=86) return true;
9550
9551 4695 break;
9552
9553 case down:
9554
4/4
✓ Branch 0 taken 5368 times.
✓ Branch 1 taken 81 times.
✓ Branch 2 taken 5172 times.
✓ Branch 3 taken 196 times.
5449 if(oy<80 && y>=80) return true;
9555
9556 5253 break;
9557
9558 case left:
9559
4/4
✓ Branch 0 taken 16665 times.
✓ Branch 1 taken 90 times.
✓ Branch 2 taken 16286 times.
✓ Branch 3 taken 379 times.
16755 if(ox>128 && x<=124) return true;
9560
9561 16376 break;
9562
9563 case right:
9564
4/4
✓ Branch 0 taken 15855 times.
✓ Branch 1 taken 81 times.
✓ Branch 2 taken 15512 times.
✓ Branch 3 taken 343 times.
15936 if(ox<120 && x>=116) return true;
9565
9566 15593 break;
9567
9568 case l_up:
9569 if(oy>80 && y<=86 && ox>128 && x<=124) return true;
9570
9571 break;
9572
9573 case l_down:
9574 if(oy<80 && y>=80 && ox>128 && x<=124) return true;
9575
9576 break;
9577
9578 case r_up:
9579 if(oy>80 && y<=86 && ox<120 && x>=116) return true;
9580
9581 break;
9582
9583 case r_down:
9584 if(oy<80 && y>=80 && ox<120 && x>=116) return true;
9585
9586 break;
9587 }
9588
9589 41917 return false;
9590 }
9591 88461 }
9592
9593 1043991 void eTrap::draw(BITMAP *dest)
9594 {
9595 1043991 update_enemy_frame();
9596 1043991 enemy::draw(dest);
9597 1043991 }
9598
9599 5705 int32_t eTrap::takehit(weapon*,weapon*)
9600 {
9601 5705 return 0;
9602 }
9603
9604 832 eTrap2::eTrap2(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
9605 832 {
9606 832 lasthit=-1;
9607 832 lasthitclk=0;
9608 832 mainguy=false;
9609
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 832 times.
832 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
9610
1/2
✓ Branch 0 taken 832 times.
✗ Branch 1 not taken.
832 step=2;
9611
3/6
✓ Branch 0 taken 433 times.
✓ Branch 1 taken 399 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 433 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
832 if(dmisc1==1 || (dmisc1==0 && zc_oldrand()&2))
9612 {
9613
2/4
✓ Branch 0 taken 399 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 399 times.
✗ Branch 3 not taken.
399 dir=(x<=112)?right:left;
9614 399 }
9615 else
9616 {
9617
2/4
✓ Branch 0 taken 433 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 433 times.
✗ Branch 3 not taken.
433 dir=(y<=72)?down:up;
9618 }
9619
9620
2/2
✓ Branch 0 taken 760 times.
✓ Branch 1 taken 72 times.
832 if(get_qr(qr_TRAPPOSFIX))
9621 {
9622
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 72 times.
✓ Branch 2 taken 72 times.
✗ Branch 3 not taken.
72 yofs = (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
9623 72 }
9624
9625 //nets+((id==eTRAP_LR)?540:520);
9626 832 dummy_int[1]=0;
9627
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 832 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
832 if (SIZEflags != 0) init_size_flags();;
9628 832 }
9629
9630 346559 bool eTrap2::animate(int32_t index)
9631 {
9632
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 346559 times.
346559 if(switch_hooked) return enemy::animate(index);
9633
2/4
✓ Branch 0 taken 346559 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 346559 times.
346559 if(fallclk||drownclk) return enemy::animate(index);
9634
2/2
✓ Branch 0 taken 335533 times.
✓ Branch 1 taken 11026 times.
346559 if(clk<0)
9635 11026 return enemy::animate(index);
9636
9637
2/2
✓ Branch 0 taken 21385 times.
✓ Branch 1 taken 314148 times.
335533 if(clk==0)
9638 {
9639 21385 removearmos(x,y,ffcactivated);
9640 21385 }
9641
9642
2/2
✓ Branch 0 taken 211207 times.
✓ Branch 1 taken 124326 times.
335533 if(!get_qr(qr_PHANTOMPLACEDTRAPS))
9643 {
9644
2/2
✓ Branch 0 taken 11074 times.
✓ Branch 1 taken 113252 times.
124326 if(lasthitclk>0)
9645 {
9646 11074 --lasthitclk;
9647 11074 }
9648 else
9649 {
9650 113252 lasthit=-1;
9651 }
9652
9653 124326 bool hitenemy=false;
9654
9655
2/2
✓ Branch 0 taken 864860 times.
✓ Branch 1 taken 124326 times.
989186 for(int32_t j=0; j<guys.Count(); j++)
9656 {
9657
4/4
✓ Branch 0 taken 740534 times.
✓ Branch 1 taken 124326 times.
✓ Branch 2 taken 10183 times.
✓ Branch 3 taken 730351 times.
864860 if((j!=index) && (lasthit!=j))
9658 {
9659
2/2
✓ Branch 0 taken 726682 times.
✓ Branch 1 taken 3669 times.
730351 if(hit(guys.spr(j)))
9660 {
9661 3669 lasthit=j;
9662 3669 lasthitclk=10;
9663 3669 hitenemy=true;
9664 3669 guys.spr(j)->lasthit=index;
9665 3669 guys.spr(j)->lasthitclk=10;
9666 // guys.spr(j)->dir=guys.spr(j)->dir^1;
9667 3669 }
9668 730351 }
9669 864860 }
9670
9671
5/6
✓ Branch 0 taken 121171 times.
✓ Branch 1 taken 3155 times.
✓ Branch 2 taken 121171 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2831 times.
✓ Branch 5 taken 118340 times.
124326 if(!trapmove(dir) || clip() || hitenemy)
9672 {
9673
3/4
✓ Branch 0 taken 2831 times.
✓ Branch 1 taken 3155 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2831 times.
5986 if(!trapmove(dir) || clip())
9674 {
9675 3155 lasthit=-1;
9676 3155 lasthitclk=0;
9677 3155 }
9678
9679
2/2
✓ Branch 0 taken 5624 times.
✓ Branch 1 taken 362 times.
5986 if(get_qr(qr_MORESOUNDS))
9680 362 sfx(WAV_ZN1TAP,pan(int32_t(x)));
9681
9682 5986 dir=dir^1;
9683 5986 }
9684
9685 124326 sprite::move(step);
9686 124326 }
9687 else
9688 {
9689
3/4
✓ Branch 0 taken 204288 times.
✓ Branch 1 taken 6919 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 204288 times.
211207 if(!trapmove(dir) || clip())
9690 {
9691
2/2
✓ Branch 0 taken 5398 times.
✓ Branch 1 taken 1521 times.
6919 if(get_qr(qr_MORESOUNDS))
9692 1521 sfx(WAV_ZN1TAP,pan(int32_t(x)));
9693
9694 6919 dir=dir^1;
9695 6919 }
9696
9697 211207 sprite::move(step);
9698 }
9699
9700 335533 return enemy::animate(index);
9701 346559 }
9702
9703 341519 bool eTrap2::trapmove(int32_t ndir)
9704 {
9705
2/2
✓ Branch 0 taken 1878 times.
✓ Branch 1 taken 339641 times.
341519 if(tmpscr->flags2&fFLOATTRAPS)
9706 1878 return canmove(ndir,(zfix)1,spw_floater, 0, 0, 15, 15,false);
9707
9708 339641 return canmove(ndir,(zfix)1,spw_water, 0, 0, 15, 15,false);
9709 341519 }
9710
9711 328290 bool eTrap2::clip()
9712 {
9713
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 88320 times.
✓ Branch 2 taken 89029 times.
✓ Branch 3 taken 75153 times.
✓ Branch 4 taken 75788 times.
328290 switch(dir)
9714 {
9715 case up:
9716
1/2
✓ Branch 0 taken 88320 times.
✗ Branch 1 not taken.
88320 if(y<=0) return true;
9717
9718 88320 break;
9719
9720 case down:
9721
1/2
✓ Branch 0 taken 89029 times.
✗ Branch 1 not taken.
89029 if(y>=160) return true;
9722
9723 89029 break;
9724
9725 case left:
9726
1/2
✓ Branch 0 taken 75153 times.
✗ Branch 1 not taken.
75153 if(x<=0) return true;
9727
9728 75153 break;
9729
9730 case right:
9731
1/2
✓ Branch 0 taken 75788 times.
✗ Branch 1 not taken.
75788 if(x>=240) return true;
9732
9733 75788 break;
9734 }
9735
9736 328290 return false;
9737 328290 }
9738
9739 350933 void eTrap2::draw(BITMAP *dest)
9740 {
9741 350933 update_enemy_frame();
9742 350933 enemy::draw(dest);
9743 350933 }
9744
9745 3169 int32_t eTrap2::takehit(weapon*,weapon*)
9746 {
9747 3169 return 0;
9748 }
9749
9750 354 eRock::eRock(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
9751 354 {
9752 //do not show "enemy appering" anim -DD
9753 354 clk=0;
9754 354 mainguy=false;
9755 354 clk2=-14;
9756 //Enemy Editor Size Tab
9757
1/2
✓ Branch 0 taken 354 times.
✗ Branch 1 not taken.
354 init_size_flags();
9758 //nets+1640;
9759 354 }
9760
9761 354 void eRock::init_size_flags()
9762 {
9763
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 354 times.
354 if ((d->SIZEflags & OVERRIDE_HIT_X_OFFSET) != 0) hxofs = d->hxofs;
9764 354 else hxofs = -2;
9765
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 354 times.
354 if ((d->SIZEflags & OVERRIDE_HIT_Y_OFFSET) != 0) hyofs = d->hyofs;
9766 354 else hyofs = -2;
9767
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 354 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
354 if (((d->SIZEflags & OVERRIDE_HIT_WIDTH) != 0) && d->hxsz >= 0) hit_width = d->hxsz;
9768 354 else hit_width = 20;
9769
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 354 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
354 if (((d->SIZEflags & OVERRIDE_HIT_HEIGHT) != 0) && d->hysz >= 0) hit_height = d->hysz;
9770 354 else hit_height = 20;
9771
9772
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 354 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
354 if (((d->SIZEflags & OVERRIDE_TILE_WIDTH) != 0) && d->txsz > 0) { txsz = d->txsz; if (txsz > 1) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
9773
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 354 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
354 if (((d->SIZEflags & OVERRIDE_TILE_HEIGHT) != 0) && d->tysz > 0) { tysz = d->tysz; if (tysz > 1) extend = 3; }
9774
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 354 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
354 if (((d->SIZEflags & OVERRIDE_HIT_Z_HEIGHT) != 0) && d->hzsz >= 0) hzsz = d->hzsz;
9775
1/2
✓ Branch 0 taken 354 times.
✗ Branch 1 not taken.
354 if ((d->SIZEflags & OVERRIDE_DRAW_X_OFFSET) != 0) xofs = (int32_t)d->xofs;
9776
1/2
✓ Branch 0 taken 354 times.
✗ Branch 1 not taken.
354 if ((d->SIZEflags & OVERRIDE_DRAW_Y_OFFSET) != 0)
9777 {
9778 yofs = (int32_t)d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
9779 yofs += (get_qr(qr_OLD_DRAWOFFSET) ? playing_field_offset : original_playing_field_offset); //this offset fixes yofs not plaing properly. -Z
9780 }
9781
9782
1/2
✓ Branch 0 taken 354 times.
✗ Branch 1 not taken.
354 if ((d->SIZEflags & OVERRIDE_DRAW_Z_OFFSET) != 0) zofs = (int32_t)d->zofs;
9783 354 }
9784
9785 121997 bool eRock::animate(int32_t index)
9786 {
9787
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 121997 times.
121997 if(switch_hooked) return enemy::animate(index);
9788
2/4
✓ Branch 0 taken 121997 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 121997 times.
121997 if(fallclk||drownclk) return enemy::animate(index);
9789
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 121997 times.
121997 if(dying)
9790 return Dead(index);
9791
9792
2/2
✓ Branch 0 taken 113621 times.
✓ Branch 1 taken 8376 times.
121997 if(clk==0)
9793 {
9794 8376 removearmos(x,y,ffcactivated);
9795 8376 }
9796
9797
2/2
✓ Branch 0 taken 121300 times.
✓ Branch 1 taken 697 times.
121997 if(++clk2==0) // start it
9798 {
9799 697 x=zc_oldrand()&0xF0;
9800 697 y=0;
9801 697 clk3=0;
9802 697 clk2=zc_oldrand()&15;
9803 697 }
9804
9805
2/2
✓ Branch 0 taken 22820 times.
✓ Branch 1 taken 99177 times.
121997 if(clk2>16) // move it
9806 {
9807
2/2
✓ Branch 0 taken 95747 times.
✓ Branch 1 taken 3430 times.
99177 if(clk3<=0) // start bounce
9808 {
9809 3430 dir=zc_oldrand()&1;
9810
9811
2/2
✓ Branch 0 taken 3063 times.
✓ Branch 1 taken 367 times.
3430 if(x<32) dir=1;
9812
9813
2/2
✓ Branch 0 taken 3133 times.
✓ Branch 1 taken 297 times.
3430 if(x>208) dir=0;
9814 3430 }
9815
9816
2/2
✓ Branch 0 taken 95993 times.
✓ Branch 1 taken 3184 times.
99177 if(clk3<13+16)
9817 {
9818 95993 x += dir ? 1 : -1; //right, left
9819 95993 dummy_int[1]=dir;
9820
9821
2/2
✓ Branch 0 taken 6852 times.
✓ Branch 1 taken 89141 times.
95993 if(clk3<2)
9822 {
9823 6852 y-=2; //up
9824 6852 dummy_int[2]=(dummy_int[1]==1)?r_up:l_up;
9825 6852 }
9826
2/2
✓ Branch 0 taken 10208 times.
✓ Branch 1 taken 78933 times.
89141 else if(clk3<5)
9827 {
9828 10208 y--; //up
9829 10208 dummy_int[2]=(dummy_int[1]==1)?r_up:l_up;
9830 10208 }
9831
2/2
✓ Branch 0 taken 10135 times.
✓ Branch 1 taken 68798 times.
78933 else if(clk3<8)
9832 {
9833 10135 dummy_int[2]=(dummy_int[1]==1)?right:left;
9834 10135 }
9835
2/2
✓ Branch 0 taken 10058 times.
✓ Branch 1 taken 58740 times.
68798 else if(clk3<11)
9836 {
9837 10058 y++; //down
9838 10058 dummy_int[2]=(dummy_int[1]==1)?r_down:l_down;
9839 10058 }
9840 else
9841 {
9842 58740 y+=2; //down
9843 58740 dummy_int[2]=(dummy_int[1]==1)?r_down:l_down;
9844 }
9845
9846 95993 ++clk3;
9847 95993 }
9848
2/2
✓ Branch 0 taken 2761 times.
✓ Branch 1 taken 423 times.
3184 else if(y<176)
9849 2761 clk3=0; // next bounce
9850 else
9851 423 clk2 = -(zc_oldrand()&63); // back to top
9852 99177 }
9853
9854 121997 return enemy::animate(index);
9855 121997 }
9856
9857 51441 void eRock::drawshadow(BITMAP *dest, bool translucent)
9858 {
9859
2/2
✓ Branch 0 taken 7191 times.
✓ Branch 1 taken 44250 times.
51441 if(clk2>=0)
9860 {
9861 44250 int32_t tempy=yofs;
9862 44250 flip = 0;
9863 44250 int32_t fdiv = frate/4;
9864
1/2
✓ Branch 0 taken 44250 times.
✗ Branch 1 not taken.
44250 int32_t efrate = fdiv == 0 ? 0 : clk/fdiv;
9865
1/2
✓ Branch 0 taken 44250 times.
✗ Branch 1 not taken.
44250 int32_t f2=get_qr(qr_NEWENEMYTILES)?
9866 44250 efrate:((clk>=(frate>>1))?1:0);
9867 44250 shadowtile = wpnsbuf[spr_shadow].tile+f2;
9868
9869 44250 yofs+=8;
9870
6/6
✓ Branch 0 taken 20474 times.
✓ Branch 1 taken 23776 times.
✓ Branch 2 taken 38962 times.
✓ Branch 3 taken 5288 times.
✓ Branch 4 taken 19073 times.
✓ Branch 5 taken 19889 times.
44250 yofs+=zc_max(0,zc_min(29-clk3,clk3));
9871
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 44250 times.
44250 if(!shadow_overpit(this))
9872 44250 sprite::drawshadow(dest, translucent);
9873 44250 yofs=tempy;
9874 44250 }
9875 51441 }
9876
9877 122078 void eRock::draw(BITMAP *dest)
9878 {
9879
4/6
✓ Branch 0 taken 17035 times.
✓ Branch 1 taken 105043 times.
✓ Branch 2 taken 17035 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 17035 times.
122078 if(clk2>=0 || fallclk||drownclk)
9880 {
9881 105043 int32_t tempdir=dir;
9882 105043 dir=dummy_int[2];
9883 105043 update_enemy_frame();
9884 105043 enemy::draw(dest);
9885 105043 dir=tempdir;
9886 105043 }
9887 122078 }
9888
9889 1014 int32_t eRock::takehit(weapon*,weapon*)
9890 {
9891 1014 return 0;
9892 }
9893
9894 30 eBoulder::eBoulder(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
9895 30 {
9896 30 clk=0;
9897 30 mainguy=false;
9898 30 clk2=-14;
9899
1/2
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
30 init_size_flags();
9900 //nets+1680;
9901 30 }
9902
9903 4440 bool eBoulder::animate(int32_t index)
9904 {
9905
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4440 times.
4440 if(switch_hooked) return enemy::animate(index);
9906
2/4
✓ Branch 0 taken 4440 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4440 times.
4440 if(fallclk||drownclk) return enemy::animate(index);
9907
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4440 times.
4440 if(dying)
9908 return Dead(index);
9909
9910
2/2
✓ Branch 0 taken 4150 times.
✓ Branch 1 taken 290 times.
4440 if(clk==0)
9911 {
9912 290 removearmos(x,y,ffcactivated);
9913 290 }
9914
9915 zfix *vert;
9916
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4440 times.
✓ Branch 2 taken 4440 times.
✗ Branch 3 not taken.
4440 vert = (moveflags & move_use_fake_z) ? &fakez : get_qr(qr_ENEMIESZAXIS) ? &z : &y;
9917
9918
2/2
✓ Branch 0 taken 4408 times.
✓ Branch 1 taken 32 times.
4440 if(++clk2==0) // start it
9919 {
9920 32 x=zc_oldrand()&0xF0;
9921 32 y=-32;
9922 32 clk3=0;
9923 32 clk2=zc_oldrand()&15;
9924 32 }
9925
9926
2/2
✓ Branch 0 taken 842 times.
✓ Branch 1 taken 3598 times.
4440 if(clk2>16) // move it
9927 {
9928
2/2
✓ Branch 0 taken 3467 times.
✓ Branch 1 taken 131 times.
3598 if(clk3<=0) // start bounce
9929 {
9930 131 dir=zc_oldrand()&1;
9931
9932
2/2
✓ Branch 0 taken 121 times.
✓ Branch 1 taken 10 times.
131 if(x<32) dir=1;
9933
9934
2/2
✓ Branch 0 taken 115 times.
✓ Branch 1 taken 16 times.
131 if(x>208) dir=0;
9935 131 }
9936
9937
2/2
✓ Branch 0 taken 3487 times.
✓ Branch 1 taken 111 times.
3598 if(clk3<13+16)
9938 {
9939 3487 x += dir ? 1 : -1; //right, left
9940 3487 dummy_int[1]=dir;
9941
9942
2/2
✓ Branch 0 taken 261 times.
✓ Branch 1 taken 3226 times.
3487 if(clk3<2)
9943 {
9944 261 y-=2; //up
9945 261 dummy_int[2]=(dummy_int[1]==1)?r_up:l_up;
9946 261 }
9947
2/2
✓ Branch 0 taken 382 times.
✓ Branch 1 taken 2844 times.
3226 else if(clk3<5)
9948 {
9949 382 y--; //up
9950 382 dummy_int[2]=(dummy_int[1]==1)?r_up:l_up;
9951 382 }
9952
2/2
✓ Branch 0 taken 376 times.
✓ Branch 1 taken 2468 times.
2844 else if(clk3<8)
9953 {
9954 376 dummy_int[2]=(dummy_int[1]==1)?right:left;
9955 376 }
9956
2/2
✓ Branch 0 taken 367 times.
✓ Branch 1 taken 2101 times.
2468 else if(clk3<11)
9957 {
9958 367 y++; //down
9959 367 dummy_int[2]=(dummy_int[1]==1)?r_down:l_down;
9960 367 }
9961 else
9962 {
9963 2101 y+=2; //down
9964 2101 dummy_int[2]=(dummy_int[1]==1)?r_down:l_down;
9965 }
9966
9967 3487 ++clk3;
9968 3487 }
9969
2/2
✓ Branch 0 taken 101 times.
✓ Branch 1 taken 10 times.
111 else if(y<176)
9970 101 clk3=0; // next bounce
9971 else
9972 10 clk2 = -(zc_oldrand()&63); // back to top
9973 3598 }
9974
9975 4440 return enemy::animate(index);
9976 4440 }
9977
9978 4440 void eBoulder::drawshadow(BITMAP *dest, bool translucent)
9979 {
9980
2/2
✓ Branch 0 taken 572 times.
✓ Branch 1 taken 3868 times.
4440 if(clk2>=0)
9981 {
9982 3868 int32_t tempy=yofs;
9983 3868 flip = 0;
9984 3868 int32_t f2=((clk<<2)/frate)<<1;
9985 3868 shadowtile = wpnsbuf[spr_shadow].tile+f2;
9986
6/6
✓ Branch 0 taken 1729 times.
✓ Branch 1 taken 2139 times.
✓ Branch 2 taken 3356 times.
✓ Branch 3 taken 512 times.
✓ Branch 4 taken 1618 times.
✓ Branch 5 taken 1738 times.
3868 yofs+=zc_max(0,zc_min(29-clk3,clk3));
9987
9988 3868 yofs+=8;
9989 3868 xofs-=8;
9990
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3868 times.
3868 if(!shadow_overpit(this))
9991 3868 sprite::drawshadow(dest, translucent);
9992 3868 xofs+=16;
9993 3868 ++shadowtile;
9994
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3868 times.
3868 if(!shadow_overpit(this))
9995 3868 sprite::drawshadow(dest, translucent);
9996 3868 yofs+=16;
9997 3868 shadowtile+=20;
9998
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3868 times.
3868 if(!shadow_overpit(this))
9999 3868 sprite::drawshadow(dest, translucent);
10000 3868 xofs-=16;
10001 3868 --shadowtile;
10002
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3868 times.
3868 if(!shadow_overpit(this))
10003 3868 sprite::drawshadow(dest, translucent);
10004 3868 xofs+=8;
10005 3868 yofs=tempy;
10006 3868 }
10007 4440 }
10008
10009 4440 void eBoulder::draw(BITMAP *dest)
10010 {
10011
4/6
✓ Branch 0 taken 572 times.
✓ Branch 1 taken 3868 times.
✓ Branch 2 taken 572 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 572 times.
4440 if(clk2>=0 || fallclk||drownclk)
10012 {
10013 3868 int32_t tempdir=dir;
10014 3868 dir=dummy_int[2];
10015 3868 update_enemy_frame();
10016 3868 dir=tempdir;
10017 3868 xofs-=8;
10018 3868 yofs-=8;
10019 3868 drawblock(dest,15);
10020 3868 xofs+=8;
10021 3868 yofs+=8;
10022 // enemy::draw(dest);
10023 3868 }
10024 4440 }
10025
10026 30 void eBoulder::init_size_flags()
10027 {
10028
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
30 if ((d->SIZEflags & OVERRIDE_HIT_X_OFFSET) != 0) hxofs = d->hxofs;
10029 30 else hxofs = -10;
10030
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
30 if ((d->SIZEflags & OVERRIDE_HIT_Y_OFFSET) != 0) hyofs = d->hyofs;
10031 30 else hyofs = -10;
10032
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
30 if (((d->SIZEflags & OVERRIDE_HIT_WIDTH) != 0) && d->hxsz >= 0) hit_width = d->hxsz;
10033 30 else hit_width = 36;
10034
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
30 if (((d->SIZEflags & OVERRIDE_HIT_HEIGHT) != 0) && d->hysz >= 0) hit_height = d->hysz;
10035 30 else hit_height = 36;
10036
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
30 if (((d->SIZEflags & OVERRIDE_HIT_Z_HEIGHT) != 0) && d->hzsz >= 0) hzsz = d->hzsz;
10037 30 else hzsz = 16; //can't be jumped
10038
10039
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
30 if (((d->SIZEflags & OVERRIDE_TILE_WIDTH) != 0) && d->txsz > 0) { txsz = d->txsz; if (txsz > 1) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
10040
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
30 if (((d->SIZEflags & OVERRIDE_TILE_HEIGHT) != 0) && d->tysz > 0) { tysz = d->tysz; if (tysz > 1) extend = 3; }
10041
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
30 if (((d->SIZEflags & OVERRIDE_HIT_WIDTH) != 0) && d->hxsz >= 0) hit_width = d->hxsz;
10042
1/2
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
30 if ((d->SIZEflags & OVERRIDE_DRAW_X_OFFSET) != 0) xofs = (int32_t)d->xofs;
10043
1/2
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
30 if ((d->SIZEflags & OVERRIDE_DRAW_Y_OFFSET) != 0)
10044 {
10045 yofs = (int32_t)d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
10046 yofs += (get_qr(qr_OLD_DRAWOFFSET) ? playing_field_offset : original_playing_field_offset); //this offset fixes yofs not plaing properly. -Z
10047 }
10048
10049
1/2
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
30 if ((d->SIZEflags & OVERRIDE_DRAW_Z_OFFSET) != 0) zofs = (int32_t)d->zofs;
10050 30 }
10051
10052 int32_t eBoulder::takehit(weapon*,weapon*)
10053 {
10054 return 0;
10055 }
10056
10057 4429 eProjectile::eProjectile(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk),
10058
2/2
✓ Branch 0 taken 531 times.
✓ Branch 1 taken 3898 times.
4429 minRange(get_qr(qr_BROKENSTATUES) ? 0 : Clk)
10059 4429 {
10060 /* fixing
10061 hp=1;
10062 */
10063 4429 mainguy=false;
10064
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 4422 times.
4429 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
10065 4429 hclk=clk; // the "no fire" range
10066 4429 clk=0;
10067 4429 clk3=96;
10068 4429 timer=0;
10069
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 4415 times.
4429 if(o_tile==0)
10070 {
10071 4415 superman=1;
10072 4415 hxofs=1000;
10073 4415 }
10074
1/4
✓ Branch 0 taken 4429 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4429 if (SIZEflags != 0) init_size_flags();;
10075 4429 }
10076
10077 2504746 bool eProjectile::animate(int32_t index)
10078 {
10079
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2504746 times.
2504746 if(switch_hooked) return enemy::animate(index);
10080
2/4
✓ Branch 0 taken 2504746 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2504746 times.
2504746 if(fallclk||drownclk) return enemy::animate(index);
10081
2/2
✓ Branch 0 taken 2492420 times.
✓ Branch 1 taken 12326 times.
2504746 if(clk==0)
10082 {
10083 12326 removearmos(x,y,ffcactivated);
10084 12326 }
10085
10086 double _MSVC2022_tmp1, _MSVC2022_tmp2;
10087 2504746 double ddir=atan2_MSVC2022_FIX(double(y-(Hero.y)),double(Hero.x-x));
10088
10089
4/4
✓ Branch 0 taken 835608 times.
✓ Branch 1 taken 1669138 times.
✓ Branch 2 taken 431977 times.
✓ Branch 3 taken 403631 times.
2504746 if((ddir<=(((-1)*PI)/4))&&(ddir>(((-3)*PI)/4)))
10090 {
10091 403631 dir=down;
10092 403631 }
10093
4/4
✓ Branch 0 taken 1348897 times.
✓ Branch 1 taken 752218 times.
✓ Branch 2 taken 431977 times.
✓ Branch 3 taken 916920 times.
2101115 else if((ddir<=(((1)*PI)/4))&&(ddir>(((-1)*PI)/4)))
10094 {
10095 916920 dir=right;
10096 916920 }
10097
4/4
✓ Branch 0 taken 790877 times.
✓ Branch 1 taken 393318 times.
✓ Branch 2 taken 431977 times.
✓ Branch 3 taken 358900 times.
1184195 else if((ddir<=(((3)*PI)/4))&&(ddir>(((1)*PI)/4)))
10098 {
10099 358900 dir=up;
10100 358900 }
10101 else
10102 {
10103 825295 dir=left;
10104 }
10105
10106
3/4
✓ Branch 0 taken 2504746 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1306267 times.
✓ Branch 3 taken 1198479 times.
2504746 if(!stunclk && ++clk3>80)
10107 {
10108
2/2
✓ Branch 0 taken 1046 times.
✓ Branch 1 taken 1197433 times.
1198479 if(dmisc1==9) // Breath type
10109 {
10110
2/2
✓ Branch 0 taken 483 times.
✓ Branch 1 taken 563 times.
1046 if(timer==0)
10111 {
10112 563 unsigned r=zc_oldrand();
10113
10114
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 557 times.
563 if(!(r&63))
10115 {
10116 6 timer=zc_oldrand()%50+50;
10117 6 }
10118 563 }
10119
10120
2/2
✓ Branch 0 taken 557 times.
✓ Branch 1 taken 489 times.
1046 if(timer>0)
10121 {
10122
2/2
✓ Branch 0 taken 370 times.
✓ Branch 1 taken 119 times.
489 if(timer%4==0)
10123 {
10124 119 FireBreath(false);
10125 119 }
10126
10127
2/2
✓ Branch 0 taken 483 times.
✓ Branch 1 taken 6 times.
489 if(--timer==0)
10128 {
10129 6 clk3=0;
10130 6 }
10131 489 }
10132 1046 }
10133
10134 else // Not breath type
10135 {
10136 1197433 unsigned r=zc_oldrand();
10137
10138
4/4
✓ Branch 0 taken 18808 times.
✓ Branch 1 taken 1178625 times.
✓ Branch 2 taken 1266 times.
✓ Branch 3 taken 17542 times.
1197433 if(!(r&63) && !HeroInRange(minRange))
10139 {
10140 17542 FireWeapon();
10141
10142
4/4
✓ Branch 0 taken 15040 times.
✓ Branch 1 taken 2502 times.
✓ Branch 2 taken 186 times.
✓ Branch 3 taken 66 times.
17794 if(get_qr(qr_BROKENSTATUES)==0 &&
10143
3/4
✓ Branch 0 taken 252 times.
✓ Branch 1 taken 14788 times.
✓ Branch 2 taken 252 times.
✗ Branch 3 not taken.
15040 ((wpn==ewFireball || wpn==ewFireball2) || dmisc1==e1tNORMAL))
10144 {
10145
2/2
✓ Branch 0 taken 13945 times.
✓ Branch 1 taken 909 times.
14854 if(!((r>>7)&15))
10146 {
10147 909 x-=4;
10148 909 FireWeapon();
10149 909 x+=4;
10150 909 }
10151 14854 }
10152
10153 17542 clk3=0;
10154 17542 }
10155 }
10156 1198479 }
10157
10158 2504746 return enemy::animate(index);
10159 2504746 }
10160
10161 2520335 void eProjectile::draw(BITMAP *dest)
10162 {
10163 2520335 update_enemy_frame();
10164 2520335 enemy::draw(dest);
10165 2520335 }
10166
10167 533 eTrigger::eTrigger(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
10168 533 {
10169 533 hxofs=1000;
10170 533 }
10171
10172 249811 void eTrigger::draw(BITMAP *dest)
10173 {
10174 249811 update_enemy_frame();
10175 249811 enemy::draw(dest);
10176 249811 }
10177
10178 void eTrigger::death_sfx()
10179 {
10180 //silent death
10181 }
10182
10183 5 eNPC::eNPC(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
10184 5 {
10185 5 o_tile+=wpnsbuf[iwNPCs].tile;
10186
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
5 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
10187 5 SIZEflags = d->SIZEflags;
10188
1/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
5 if (SIZEflags != 0) init_size_flags();;
10189 5 }
10190
10191 75 bool eNPC::animate(int32_t index)
10192 {
10193
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 75 times.
75 if(switch_hooked) return enemy::animate(index);
10194
2/2
✓ Branch 0 taken 70 times.
✓ Branch 1 taken 5 times.
75 if(dying)
10195 70 return Dead(index);
10196
10197
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 if(clk==0)
10198 {
10199 removearmos(x,y,ffcactivated);
10200 }
10201
10202
1/3
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
5 switch(dmisc2)
10203 {
10204 case 0:
10205 {
10206 double _MSVC2022_tmp1, _MSVC2022_tmp2;
10207 5 double ddir=atan2_MSVC2022_FIX(double(y-(Hero.y)),double(Hero.x-x));
10208
10209
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
5 if((ddir<=(((-1)*PI)/4))&&(ddir>(((-3)*PI)/4)))
10210 {
10211 dir=down;
10212 }
10213
10214
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
5 else if((ddir<=(((1)*PI)/4))&&(ddir>(((-1)*PI)/4)))
10215 {
10216 5 dir=right;
10217 5 }
10218 else if((ddir<=(((3)*PI)/4))&&(ddir>(((1)*PI)/8)))
10219 {
10220 dir=up;
10221 }
10222 else
10223 {
10224 dir=left;
10225 }
10226 }
10227 5 break;
10228
10229 case 1:
10230 halting_walk(rate, homing, 0, hrate, 48);
10231
10232 if(clk2==1 && (misc < dmisc1) && !(zc_oldrand()&15))
10233 {
10234 newdir(rate, homing, 0);
10235 clk2=48;
10236 ++misc;
10237 }
10238
10239 if(clk2==0)
10240 misc=0;
10241
10242 break;
10243 }
10244
10245 5 return enemy::animate(index);
10246 75 }
10247
10248 75 void eNPC::draw(BITMAP *dest)
10249 {
10250 75 update_enemy_frame();
10251 75 enemy::draw(dest);
10252 75 }
10253
10254 int32_t eNPC::takehit(weapon*,weapon*)
10255 {
10256 return 0;
10257 }
10258
10259 94 eSpinTile::eSpinTile(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
10260 94 {
10261
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 94 times.
94 if(clk>0) // clk>0 when created by a Spinning Tile combo
10262 {
10263 94 o_tile=clk;
10264 94 cs=id>>12;
10265 94 }
10266
10267 94 id=id&0xFFF;
10268 94 clk=0;
10269
1/2
✓ Branch 0 taken 94 times.
✗ Branch 1 not taken.
94 step=0;
10270 94 mainguy=false;
10271 94 SIZEflags = d->SIZEflags;
10272
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 94 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
94 if (SIZEflags != 0) init_size_flags();;
10273 94 }
10274
10275 81 void eSpinTile::facehero()
10276 {
10277
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 80 times.
81 if(Hero.x-x==0)
10278 {
10279
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if (Hero.y + 8 < y)
10280 1 dir = up;
10281 else
10282 dir = down;
10283 1 }
10284 else
10285 {
10286 double _MSVC2022_tmp1, _MSVC2022_tmp2;
10287 80 double ddir=atan2_MSVC2022_FIX(double(y-(Hero.y)),double(Hero.x-x));
10288
10289
4/4
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 58 times.
✓ Branch 2 taken 10 times.
✓ Branch 3 taken 12 times.
80 if((ddir <= -5.0*PI/8.0) && (ddir > -7.0*PI/8.0))
10290 {
10291 12 dir=l_down;
10292 12 }
10293
4/4
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 57 times.
✓ Branch 2 taken 10 times.
✓ Branch 3 taken 1 times.
68 else if ((ddir <= -3.0*PI / 8.0) && (ddir > -5.0*PI / 8.0))
10294 {
10295 1 dir=down;
10296 1 }
10297
4/4
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 45 times.
✓ Branch 2 taken 10 times.
✓ Branch 3 taken 12 times.
67 else if ((ddir <= -1.0*PI / 8.0) && (ddir > -3.0*PI / 8.0))
10298 {
10299 12 dir=r_down;
10300 12 }
10301
4/4
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 39 times.
✓ Branch 2 taken 10 times.
✓ Branch 3 taken 6 times.
55 else if ((ddir <= 1.0*PI / 8.0) && (ddir > -1.0*PI / 8.0))
10302 {
10303 6 dir=right;
10304 6 }
10305
4/4
✓ Branch 0 taken 27 times.
✓ Branch 1 taken 22 times.
✓ Branch 2 taken 10 times.
✓ Branch 3 taken 17 times.
49 else if ((ddir <= 3.0*PI / 8.0) && (ddir > 1.0*PI / 8.0))
10306 {
10307 17 dir=r_up;
10308 17 }
10309
4/4
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 14 times.
✓ Branch 2 taken 10 times.
✓ Branch 3 taken 8 times.
32 else if ((ddir <= 5.0*PI / 8.0) && (ddir > 3.0*PI / 8.0))
10310 {
10311 8 dir=up;
10312 8 }
10313
4/4
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 8 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 10 times.
24 else if ((ddir <= 7.0*PI / 8.0) && (ddir > 5.0*PI / 8.0))
10314 {
10315 6 dir=l_up;
10316 6 }
10317 else
10318 {
10319 18 dir=left;
10320 }
10321 }
10322 81 }
10323
10324
10325 15539 bool eSpinTile::animate(int32_t index)
10326 {
10327
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15539 times.
15539 if(switch_hooked) return enemy::animate(index);
10328
2/4
✓ Branch 0 taken 15539 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 15539 times.
15539 if(fallclk||drownclk) return enemy::animate(index);
10329
2/2
✓ Branch 0 taken 1152 times.
✓ Branch 1 taken 14387 times.
15539 if(dying)
10330 {
10331 1152 return Dead(index);
10332 }
10333
10334
2/2
✓ Branch 0 taken 13146 times.
✓ Branch 1 taken 1241 times.
14387 if(clk==0)
10335 {
10336 1241 removearmos(x,y,ffcactivated);
10337 1241 }
10338
10339 14387 ++misc;
10340
10341
2/2
✓ Branch 0 taken 14306 times.
✓ Branch 1 taken 81 times.
14387 if(misc==96)
10342 {
10343 81 facehero();
10344 double _MSVC2022_tmp1, _MSVC2022_tmp2;
10345 81 double ddir=atan2_MSVC2022_FIX(double((Hero.y)-y),double(Hero.x-x));
10346 81 angular=true;
10347 81 angle=ddir;
10348 81 step=zslongToFix(dstep*100);
10349 81 }
10350
10351
8/8
✓ Branch 0 taken 14374 times.
✓ Branch 1 taken 13 times.
✓ Branch 2 taken 14359 times.
✓ Branch 3 taken 15 times.
✓ Branch 4 taken 14353 times.
✓ Branch 5 taken 6 times.
✓ Branch 6 taken 18 times.
✓ Branch 7 taken 14335 times.
14387 if(y>186 || y<=-16 || x>272 || x<=-16)
10352 52 kickbucket();
10353
10354 14387 sprite::move(step);
10355 14387 return enemy::animate(index);
10356 15539 }
10357
10358 15457 void eSpinTile::draw(BITMAP *dest)
10359 {
10360 15457 update_enemy_frame();
10361 15457 y-=(misc>>4);
10362 15457 yofs+=2;
10363 15457 enemy::draw(dest);
10364 15457 yofs-=2;
10365 15457 y+=(misc>>4);
10366 15457 }
10367
10368 15457 void eSpinTile::drawshadow(BITMAP *dest, bool translucent)
10369 {
10370 15457 flip = 0;
10371 15457 shadowtile = wpnsbuf[spr_shadow].tile+(clk%4);
10372 15457 yofs+=4;
10373
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15457 times.
15457 if(!shadow_overpit(this))
10374 15457 enemy::drawshadow(dest, translucent);
10375 15457 yofs-=4;
10376 15457 }
10377
10378 2765 eZora::eZora(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,0)
10379 2765 {
10380 //these are here to bypass compiler warnings about unused arguments
10381 2765 Clk=Clk;
10382 2765 mainguy=false;
10383
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2765 times.
2765 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
10384 /*if((x>-17 && x<0) && iswaterex(tmpscr->data[(((int32_t)y&0xF0)+((int32_t)x>>4))]))
10385 {
10386 clk=1;
10387 }*/
10388 //nets+880;
10389
1/4
✓ Branch 0 taken 2765 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2765 if (SIZEflags != 0) init_size_flags();;
10390 2765 }
10391
10392 623626 void eZora::facehero()
10393 {
10394
2/2
✓ Branch 0 taken 10785 times.
✓ Branch 1 taken 612841 times.
623626 if(Hero.x-x==0)
10395 {
10396 10785 dir=(Hero.y+8<y)?up:down;
10397 10785 }
10398 else
10399 {
10400 double _MSVC2022_tmp1, _MSVC2022_tmp2;
10401 612841 double ddir=atan2_MSVC2022_FIX(double(y-(Hero.y)),double(Hero.x-x));
10402
10403
4/4
✓ Branch 0 taken 124342 times.
✓ Branch 1 taken 488499 times.
✓ Branch 2 taken 46030 times.
✓ Branch 3 taken 78312 times.
612841 if((ddir<=(((-5)*PI)/8))&&(ddir>(((-7)*PI)/8)))
10404 {
10405 78312 dir=l_down;
10406 78312 }
10407
4/4
✓ Branch 0 taken 90275 times.
✓ Branch 1 taken 444254 times.
✓ Branch 2 taken 46030 times.
✓ Branch 3 taken 44245 times.
534529 else if((ddir<=(((-3)*PI)/8))&&(ddir>(((-5)*PI)/8)))
10408 {
10409 44245 dir=down;
10410 44245 }
10411
4/4
✓ Branch 0 taken 119526 times.
✓ Branch 1 taken 370758 times.
✓ Branch 2 taken 46030 times.
✓ Branch 3 taken 73496 times.
490284 else if((ddir<=(((-1)*PI)/8))&&(ddir>(((-3)*PI)/8)))
10412 {
10413 73496 dir=r_down;
10414 73496 }
10415
4/4
✓ Branch 0 taken 160722 times.
✓ Branch 1 taken 256066 times.
✓ Branch 2 taken 46030 times.
✓ Branch 3 taken 114692 times.
416788 else if((ddir<=(((1)*PI)/8))&&(ddir>(((-1)*PI)/8)))
10416 {
10417 114692 dir=right;
10418 114692 }
10419
4/4
✓ Branch 0 taken 125815 times.
✓ Branch 1 taken 176281 times.
✓ Branch 2 taken 46030 times.
✓ Branch 3 taken 79785 times.
302096 else if((ddir<=(((3)*PI)/8))&&(ddir>(((1)*PI)/8)))
10420 {
10421 79785 dir=r_up;
10422 79785 }
10423
4/4
✓ Branch 0 taken 87885 times.
✓ Branch 1 taken 134426 times.
✓ Branch 2 taken 46030 times.
✓ Branch 3 taken 41855 times.
222311 else if((ddir<=(((5)*PI)/8))&&(ddir>(((3)*PI)/8)))
10424 {
10425 41855 dir=up;
10426 41855 }
10427
4/4
✓ Branch 0 taken 120580 times.
✓ Branch 1 taken 59876 times.
✓ Branch 2 taken 74550 times.
✓ Branch 3 taken 46030 times.
180456 else if((ddir<=(((7)*PI)/8))&&(ddir>(((5)*PI)/8)))
10428 {
10429 74550 dir=l_up;
10430 74550 }
10431 else
10432 {
10433 105906 dir=left;
10434 }
10435 }
10436 623626 }
10437
10438 852265 bool eZora::animate(int32_t index)
10439 {
10440
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 852265 times.
852265 if(switch_hooked) return enemy::animate(index);
10441
2/2
✓ Branch 0 taken 2754 times.
✓ Branch 1 taken 849511 times.
852265 if(dying)
10442 2754 return Dead(index);
10443
10444
2/2
✓ Branch 0 taken 843799 times.
✓ Branch 1 taken 5712 times.
849511 if(clk==0)
10445 {
10446 5712 removearmos(x,y,ffcactivated);
10447 5712 }
10448
10449
2/2
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 849476 times.
849511 if(watch)
10450 {
10451 35 ++clock_zoras[id];
10452 35 return true;
10453 }
10454
10455
2/2
✓ Branch 0 taken 225850 times.
✓ Branch 1 taken 623626 times.
849476 if(get_qr(qr_NEWENEMYTILES))
10456 {
10457 623626 facehero();
10458 623626 }
10459
10460
6/6
✓ Branch 0 taken 5200 times.
✓ Branch 1 taken 4963 times.
✓ Branch 2 taken 4164 times.
✓ Branch 3 taken 825736 times.
✓ Branch 4 taken 6448 times.
✓ Branch 5 taken 2965 times.
849476 switch(clk)
10461 {
10462 case 0: // reposition him
10463 {
10464 6448 int32_t t=0;
10465 6448 int32_t pos2=zc_oldrand()%160 + 16;
10466 6448 bool placed=false;
10467
10468
4/4
✓ Branch 0 taken 6383 times.
✓ Branch 1 taken 38203 times.
✓ Branch 2 taken 26108 times.
✓ Branch 3 taken 5712 times.
44586 while(!placed && t<160)
10469 {
10470 26108 int32_t watertype = iswaterex(tmpscr->data[pos2], currmap, currscr, -1, ((pos2)%16*16), ((pos2)&0xF0), false, true, true, (bool)(editorflags & ENEMY_FLAG7));
10471
5/6
✓ Branch 0 taken 6570 times.
✓ Branch 1 taken 19538 times.
✓ Branch 2 taken 6570 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 400 times.
✓ Branch 5 taken 5647 times.
32155 if(watertype && ((editorflags & ENEMY_FLAG6) ||
10472
2/2
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 6538 times.
6570 ((combobuf[watertype].usrflags&cflag1) && (editorflags & ENEMY_FLAG5))
10473
3/4
✓ Branch 0 taken 6538 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6047 times.
✓ Branch 3 taken 6015 times.
6570 || (!(combobuf[watertype].usrflags&cflag1) && !(editorflags & ENEMY_FLAG5))) && (pos2&15)>0 && (pos2&15)<15)
10474 {
10475 5647 x=(pos2&15)<<4;
10476 5647 y=pos2&0xF0;
10477
2/2
✓ Branch 0 taken 340 times.
✓ Branch 1 taken 5307 times.
5647 if (!(editorflags & ENEMY_FLAG8)) hp=guysbuf[id&0xFFF].hp; // refill life each time, unless the flag is checked.
10478 5647 hxofs=1000; // avoid hit detection
10479 5647 stunclk=0;
10480 5647 placed=true;
10481 5647 }
10482
10483 38138 pos2+=19;
10484
10485
2/2
✓ Branch 0 taken 33615 times.
✓ Branch 1 taken 4523 times.
38138 if(pos2>=176)
10486 4523 pos2-=160;
10487
10488 38138 ++t;
10489 }
10490
10491
3/4
✓ Branch 0 taken 5647 times.
✓ Branch 1 taken 65 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5647 times.
5712 if(!placed || whistleclk>=88) // can't place him, he's gone
10492 65 return true;
10493
10494 }
10495 5647 break;
10496
10497 case 35:
10498
2/2
✓ Branch 0 taken 3839 times.
✓ Branch 1 taken 1361 times.
5200 if(!get_qr(qr_NEWENEMYTILES))
10499 {
10500 1361 dir=(Hero.y+8<y)?up:down;
10501 1361 }
10502
10503 5200 hxofs=0;
10504 5200 break;
10505
10506 case 35+19:
10507 4963 addEwpn(x,y,z,wpn,2,wdp,dir,getUID(), 0, fakez);
10508 4963 sfx(wpnsfx(wpn),pan(int32_t(x)));
10509 4963 break;
10510
10511 case 35+66:
10512 4164 hxofs=1000;
10513 4164 break;
10514
10515 case 198:
10516 2965 clk=-1;
10517 2965 break;
10518 }
10519
10520 848675 return enemy::animate(index);
10521 851529 }
10522
10523 857650 void eZora::draw(BITMAP *dest)
10524 {
10525
2/2
✓ Branch 0 taken 16963 times.
✓ Branch 1 taken 840687 times.
857650 if(clk<3)
10526 16963 return;
10527
10528 840687 update_enemy_frame();
10529 840687 enemy::draw(dest);
10530 857650 }
10531
10532 232 bool eZora::isSubmerged() const
10533 {
10534 232 return ( clk < 3 );
10535 }
10536
10537
3/6
✓ Branch 0 taken 50114 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 50114 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 50114 times.
✗ Branch 5 not taken.
100228 eStalfos::eStalfos(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
10538 50114 {
10539 50114 multishot= timer = fired = dashing = 0;
10540 50114 hashero = false;
10541 50114 dummy_bool[0]=false;
10542
4/8
✓ Branch 0 taken 50114 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 50114 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 50114 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 50114 times.
✗ Branch 7 not taken.
50114 shield= (flags&(guy_shield_left | guy_shield_right | guy_shield_back |guy_shield_front)) != 0;
10543
5/6
✓ Branch 0 taken 960 times.
✓ Branch 1 taken 49154 times.
✓ Branch 2 taken 960 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 495 times.
✓ Branch 5 taken 465 times.
50114 if(dmisc9==e9tARMOS && zc_oldrand()&1)
10544 {
10545
2/4
✓ Branch 0 taken 495 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 495 times.
✗ Branch 3 not taken.
495 step=zslongToFix(dmisc10*100);
10546
10547
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 477 times.
495 if(anim==aARMOS4) o_tile+=20;
10548 495 }
10549
10550
3/4
✓ Branch 0 taken 50114 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 960 times.
✓ Branch 3 taken 49154 times.
50114 if(flags & guy_fade_flicker)
10551 {
10552 960 clk=0;
10553 960 superman = 1;
10554 960 fading=fade_flicker;
10555
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 960 times.
960 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
10556 960 dir=down;
10557
10558
4/6
✓ Branch 0 taken 960 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 960 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 409 times.
✓ Branch 5 taken 551 times.
960 if(!canmove(down,(zfix)8,spw_none,false))
10559
3/6
✓ Branch 0 taken 409 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 409 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 409 times.
✗ Branch 5 not taken.
409 clk3=int32_t(13.0/step);
10560 960 }
10561
3/4
✓ Branch 0 taken 49154 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 49021 times.
✓ Branch 3 taken 133 times.
49154 else if(flags & guy_fade_instant)
10562 {
10563 133 clk=0;
10564 133 }
10565
10566
1/2
✓ Branch 0 taken 50114 times.
✗ Branch 1 not taken.
50114 shadowdistance = 0;
10567 50114 clk4 = clk5 = 0;
10568 //nets+2380;
10569
3/4
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 50112 times.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
50114 if (SIZEflags != 0) init_size_flags();;
10570 50114 }
10571
10572 15797387 bool eStalfos::animate(int32_t index)
10573 {
10574
2/2
✓ Branch 0 taken 256 times.
✓ Branch 1 taken 15797131 times.
15797387 if(switch_hooked) return enemy::animate(index);
10575
3/4
✓ Branch 0 taken 15796705 times.
✓ Branch 1 taken 426 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 15796705 times.
15797131 if(fallclk||drownclk)
10576 {
10577 426 return enemy::animate(index);
10578 }
10579
2/2
✓ Branch 0 taken 352672 times.
✓ Branch 1 taken 15444033 times.
15796705 if(dying)
10580 {
10581
2/2
✓ Branch 0 taken 352624 times.
✓ Branch 1 taken 48 times.
352672 if(hashero)
10582 {
10583 48 Hero.setEaten(0);
10584 48 hashero=false;
10585 48 }
10586
10587
10/14
✓ Branch 0 taken 35920 times.
✓ Branch 1 taken 316752 times.
✓ Branch 2 taken 3685 times.
✓ Branch 3 taken 32235 times.
✓ Branch 4 taken 187 times.
✓ Branch 5 taken 3498 times.
✓ Branch 6 taken 187 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 187 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 187 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✓ Branch 13 taken 187 times.
352672 if(dmisc9==e9tROPE && dmisc2==e2tBOMBCHU && !fired && (hp<=0 && !immortal) && hp>-1000 && wpn>wEnemyWeapons)
10588 {
10589 187 hp=-1000;
10590
5/10
✓ Branch 0 taken 187 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 187 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 187 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 187 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 187 times.
✗ Branch 9 not taken.
187 weapon *ew=new weapon(x,y,z, wpn, 0, dmisc4, dir,-1,getUID(),false);
10591 187 Ewpns.add(ew);
10592 187 ew->fakez = fakez;
10593
10594
3/4
✓ Branch 0 taken 119 times.
✓ Branch 1 taken 68 times.
✓ Branch 2 taken 119 times.
✗ Branch 3 not taken.
187 if(wpn==ewSBomb || wpn==ewBomb)
10595 {
10596 187 ew->step=0;
10597 187 ew->id=wpn;
10598 187 ew->misc=50;
10599 187 ew->clk=48;
10600 187 }
10601
10602 187 fired=true;
10603 187 }
10604
6/6
✓ Branch 0 taken 156252 times.
✓ Branch 1 taken 196233 times.
✓ Branch 2 taken 130200 times.
✓ Branch 3 taken 26052 times.
✓ Branch 4 taken 130182 times.
✓ Branch 5 taken 18 times.
352485 else if(wpn && wpn!=ewBrang && dmisc2==e2tFIREOCTO) // Fire Octo
10605 {
10606
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 1 times.
18 if(!dummy_bool[0])
10607 {
10608 1 int32_t wpn2 = wpn+dmisc3;
10609
10610
2/4
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
1 if(wpn2 <= wEnemyWeapons || wpn2 >= wMax)
10611 {
10612 wpn2=wpn;
10613 }
10614
10615 1 dummy_bool[0]=true;
10616 1 addEwpn(x,y,z,wpn2,0,dmisc4,up, getUID(), 0, fakez);
10617 1 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
10618 1 addEwpn(x,y,z,wpn2,0,dmisc4,down, getUID(), 0, fakez);
10619 1 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
10620 1 addEwpn(x,y,z,wpn2,0,dmisc4,left, getUID(), 0, fakez);
10621 1 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
10622 1 addEwpn(x,y,z,wpn2,0,dmisc4,right, getUID(), 0, fakez);
10623 1 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
10624 1 addEwpn(x,y,z,wpn2,0,dmisc4,l_up, getUID(), 0, fakez);
10625 1 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
10626 1 addEwpn(x,y,z,wpn2,0,dmisc4,r_up, getUID(), 0, fakez);
10627 1 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
10628 1 addEwpn(x,y,z,wpn2,0,dmisc4,l_down, getUID(), 0, fakez);
10629 1 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
10630 1 addEwpn(x,y,z,wpn2,0,dmisc4,r_down, getUID(), 0, fakez);
10631 1 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
10632 1 sfx(wpnsfx(wpn2),pan(int32_t(x)));
10633 1 }
10634 18 }
10635
10636 352672 KillWeapon();
10637 352672 return Dead(index);
10638 }
10639 //vire split
10640 //2.10 checked !fslide(), but nothing uses that now anyway. -Z
10641 //Perhaps the problem occurs when vires die because they have < 0 HP, in this check?
10642
13/14
✓ Branch 0 taken 21124 times.
✓ Branch 1 taken 15422909 times.
✓ Branch 2 taken 21124 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 351 times.
✓ Branch 5 taken 20773 times.
✓ Branch 6 taken 1192696 times.
✓ Branch 7 taken 14250986 times.
✓ Branch 8 taken 1191149 times.
✓ Branch 9 taken 1547 times.
✓ Branch 10 taken 6686 times.
✓ Branch 11 taken 1184463 times.
✓ Branch 12 taken 1326 times.
✓ Branch 13 taken 5360 times.
15444033 else if(((hp<=0 && !immortal) && dmisc2==e2tSPLIT) || (dmisc2==e2tSPLITHIT && hp>0 && hp<guysbuf[id&0xFFF].hp && !slide() && (sclk&255)<=1)) //Split into enemies
10643 {
10644 1677 stop_bgsfx(index);
10645 1677 int32_t kids = guys.Count();
10646 1677 int32_t id2=dmisc3;
10647
2/2
✓ Branch 0 taken 3307 times.
✓ Branch 1 taken 1677 times.
4984 for(int32_t i=0; i < dmisc4; i++)
10648 {
10649 // if (addenemy(x,y,id2+(guysbuf[id2].family==eeKEESE ? 0 : ((i+1)<<12)),-21-(i%4)))
10650
4/6
✓ Branch 0 taken 1272 times.
✓ Branch 1 taken 2035 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2035 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 3307 times.
3307 if(addenemy(x,y,id2+(guysbuf[id2].family==eeKEESE ? 0 : ((editorflags & ENEMY_FLAG5) ? 0 : (i<<12))),-21-(i%4)))
10651 3307 ((enemy*)guys.spr(kids+i))->count_enemy = false;
10652 3307 }
10653
10654
2/2
✓ Branch 0 taken 1676 times.
✓ Branch 1 taken 1 times.
1677 if(itemguy) // Hand down the carried item
10655 {
10656 1 guycarryingitem = guys.Count()-1;
10657 1 ((enemy*)guys.spr(guycarryingitem))->itemguy = true;
10658 1 itemguy = false;
10659 1 }
10660
10661
2/2
✓ Branch 0 taken 1660 times.
✓ Branch 1 taken 17 times.
1677 if(hashero)
10662 {
10663 17 Hero.setEaten(0);
10664 17 hashero=false;
10665 17 }
10666
10667
4/4
✓ Branch 0 taken 1649 times.
✓ Branch 1 taken 28 times.
✓ Branch 2 taken 1326 times.
✓ Branch 3 taken 323 times.
1677 if(deadsfx > 0 && dmisc2==e2tSPLIT)
10668 323 sfx(deadsfx,pan(int32_t(x)));
10669
10670 1677 return true;
10671 }
10672 /*
10673 else if((dmisc2==e2tSPLITHIT && (hp<=0 && !immortal) &&!slide())) //Possible vires fix; or could cause goodness knows what. -Z
10674 {
10675 stop_bgsfx(index);
10676 int32_t kids = guys.Count();
10677 int32_t id2=dmisc3;
10678
10679 for(int32_t i=0; i < dmisc4; i++)
10680 {
10681 // if (addenemy(x,y,id2+(guysbuf[id2].family==eeKEESE ? 0 : ((i+1)<<12)),-21-(i%4)))
10682 if(addenemy(x,y,id2+(guysbuf[id2].family==eeKEESE ? 0 : (i<<12)),-21-(i%4)))
10683 ((enemy*)guys.spr(kids+i))->count_enemy = false;
10684 }
10685
10686 if(itemguy) // Hand down the carried item
10687 {
10688 guycarryingitem = guys.Count()-1;
10689 ((enemy*)guys.spr(guycarryingitem))->itemguy = true;
10690 itemguy = false;
10691 }
10692
10693 if(hashero)
10694 {
10695 Hero.setEaten(0);
10696 hashero=false;
10697 }
10698
10699 return true;
10700 }
10701 */
10702
2/2
✓ Branch 0 taken 68836 times.
✓ Branch 1 taken 15373520 times.
15442356 if(fading)
10703 {
10704
2/2
✓ Branch 0 taken 1190 times.
✓ Branch 1 taken 67646 times.
68836 if(++clk4 > 60)
10705 {
10706 1190 clk4=0;
10707 1190 superman=0;
10708 1190 fading=0;
10709
10710
4/6
✓ Branch 0 taken 929 times.
✓ Branch 1 taken 261 times.
✓ Branch 2 taken 929 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 929 times.
1190 if(flags&guy_armos && z==0 && fakez == 0)
10711 {
10712 //if a custom size (not 16px by 16px)
10713
10714 //if a custom size (not 16px by 16px)
10715
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 929 times.
929 if (ffcactivated)
10716 removearmosffc(ffcactivated-1);
10717 else
10718 {
10719
4/8
✓ Branch 0 taken 929 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 929 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 929 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 929 times.
929 if (txsz > 1 || tysz > 1 || (SIZEflags&OVERRIDE_HIT_WIDTH) || (SIZEflags&OVERRIDE_HIT_HEIGHT) )//remove more than one combo based on enemy size
10720 {
10721 //zprint("spawn big enemy from armos\n");
10722 //if removing a block, then adjust y by -1 as the enemy spawns at y+1
10723 for(int32_t dx = 0; dx < tysz; dx ++)
10724 {
10725 for(int32_t dy = 0; dy < tysz; dy++)
10726 {
10727 removearmos((int32_t)x+(dx*16),(int32_t)y+(dy*16)+1);
10728 did_armos = false;
10729 }
10730 removearmos((int32_t)x+(dx*16), (int32_t)y+((tysz-1)*16)+1);
10731 did_armos = false;
10732 }
10733 for(int32_t dy = 0; dy < tysz; dy ++)
10734 {
10735 removearmos((int32_t)x+((txsz-1)*16), (int32_t)y+(dy*16)+1);
10736 did_armos = false;
10737 }
10738 removearmos((int32_t)x+((txsz-1)*16), (int32_t)y+((tysz-1)*16)+1);
10739 }
10740 929 else removearmos(x,y);
10741 }
10742 /*
10743 if (txsz > 1 || tysz > 1 || (SIZEflags&guyflagOVERRIDE_HIT_WIDTH) || (SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) )//remove more than one combo based on enemy size
10744 {
10745 //if removing a block, then adjust y by -1 as the enemy spawns at y+1
10746 for(int32_t dx = 0; dx < hxsz; dx += 16)
10747 {
10748 for(int32_t dy = 0; dy < hysz; dy += 16)
10749 {
10750 removearmos((int32_t)x+dx+hxofs,(int32_t)y+dy+hyofs+1,ffcactivated);
10751 did_armos = false;
10752 }
10753 removearmos((int32_t)x+dx+hxofs, (int32_t)y+hyofs+(hysz-1)-1,ffcactivated);
10754 did_armos = false;
10755 }
10756 for(int32_t dy = 0; dy < hysz; dy += 16)
10757 {
10758 removearmos((int32_t)x+hxofs+(hxsz-1), (int32_t)y+dy+hyofs-1,ffcactivated);
10759 did_armos = false;
10760 }
10761 removearmos((int32_t)x+hxofs+(hxsz-1), (int32_t)y+hyofs+(hysz-1)-1,ffcactivated);
10762 }
10763 else removearmos(x,y,ffcactivated);
10764 */
10765
10766 929 }
10767
10768 1190 clk2=0;
10769
10770 1190 newdir();
10771 1190 }
10772 67646 else return enemy::animate(index);
10773 1190 }
10774
6/8
✓ Branch 0 taken 143173 times.
✓ Branch 1 taken 15230347 times.
✓ Branch 2 taken 143173 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 143173 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 133968 times.
✓ Branch 7 taken 9205 times.
15373520 else if(flags&guy_armos && z==0 && fakez == 0 && clk==0)
10775 9205 removearmos(x,y,ffcactivated);
10776
10777
10778
2/2
✓ Branch 0 taken 7207 times.
✓ Branch 1 taken 15367503 times.
15374710 if(hashero)
10779 {
10780 7207 Hero.setX(x);
10781 7207 Hero.setY(y);
10782 7207 ++clk2;
10783
10784
4/4
✓ Branch 0 taken 5694 times.
✓ Branch 1 taken 1513 times.
✓ Branch 2 taken 6308 times.
✓ Branch 3 taken 899 times.
7207 if(clk2==(dmisc8==0 ? 95 : dmisc8))
10785 {
10786
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 877 times.
✓ Branch 2 taken 22 times.
✗ Branch 3 not taken.
899 switch(dmisc7)
10787 {
10788 case e7tEATITEMS:
10789 {
10790
2/2
✓ Branch 0 taken 5632 times.
✓ Branch 1 taken 22 times.
5654 for(int32_t i=0; i<MAXITEMS; i++)
10791 {
10792
2/2
✓ Branch 0 taken 5610 times.
✓ Branch 1 taken 22 times.
5632 if(itemsbuf[i].flags&item_edible)
10793 22 game->set_item(i, false);
10794 5632 }
10795
10796 22 break;
10797 }
10798
10799 case e7tEATMAGIC:
10800 game->change_dmagic(-1*game->get_magicdrainrate());
10801 break;
10802
10803 case e7tEATRUPEES:
10804 game->change_drupy(-1);
10805 break;
10806 }
10807
10808 899 clk2=0;
10809 899 }
10810
10811
2/2
✓ Branch 0 taken 546 times.
✓ Branch 1 taken 6661 times.
7207 if((clk&0x18)==8) // stop its animation on the middle frame
10812 6661 --clk;
10813 7207 }
10814
4/4
✓ Branch 0 taken 1048873 times.
✓ Branch 1 taken 14318630 times.
✓ Branch 2 taken 616037 times.
✓ Branch 3 taken 432836 times.
15367503 else if(!(wpn==ewBrang && WeaponOut())) //WeaponOut uses misc
10815 {
10816 // Movement engine
10817
6/6
✓ Branch 0 taken 838865 times.
✓ Branch 1 taken 14095802 times.
✓ Branch 2 taken 3294 times.
✓ Branch 3 taken 108 times.
✓ Branch 4 taken 14092341 times.
✓ Branch 5 taken 59 times.
14934667 if(clk>=0) switch(id>>12)
10818 {
10819 case 0: // Normal movement
10820
10821 /*
10822 if((dmisc9==e9tLEEVER || dmisc9==e9tZ3LEEVER) && !slide()) //Leever
10823 {
10824 // Overloading clk4 (Tribble clock) here...
10825 step=17/100.0;
10826 if(clk4<32) misc=1;
10827 else if(clk4<48) misc=2;
10828 else if(clk4<300) { misc=3; step = dstep/100.0; }
10829 else if(clk4<316) misc=2;
10830 else if(clk4<412) misc=1;
10831 else if(clk4<540) { misc=0; step=0; }
10832 else clk4=0;
10833 if(clk4==48) clk=0;
10834 hxofs=(misc>=2)?0:1000;
10835 if (dmisc9==e9tLEEVER)
10836 variable_walk(rate, homing, 0);
10837 else
10838 variable_walk_8(rate, homing, 4, 0);
10839 break;
10840 }
10841 */
10842
4/4
✓ Branch 0 taken 13713307 times.
✓ Branch 1 taken 379034 times.
✓ Branch 2 taken 417076 times.
✓ Branch 3 taken 13296231 times.
14092341 if(dmisc9==e9tVIRE || dmisc9==e9tPOLSVOICE) //Vire
10843 {
10844 796110 vire_hop();
10845 796110 break;
10846 }
10847
2/2
✓ Branch 0 taken 981551 times.
✓ Branch 1 taken 12314680 times.
13296231 else if(dmisc9==e9tROPE) //Rope charge
10848 {
10849
9/10
✓ Branch 0 taken 964129 times.
✓ Branch 1 taken 17422 times.
✓ Branch 2 taken 138340 times.
✓ Branch 3 taken 825789 times.
✓ Branch 4 taken 126255 times.
✓ Branch 5 taken 12085 times.
✓ Branch 6 taken 125430 times.
✓ Branch 7 taken 825 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 125430 times.
981551 if(!fired && dashing && !stunclk && !watch && !frozenclock)
10850 {
10851
5/6
✓ Branch 0 taken 9076 times.
✓ Branch 1 taken 116354 times.
✓ Branch 2 taken 47 times.
✓ Branch 3 taken 9029 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 47 times.
125430 if(dmisc2==e2tBOMBCHU && HeroInRange(16) && wpn+dmisc3 > wEnemyWeapons) //Bombchu
10852 {
10853
10854
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 33 times.
47 if ( get_qr(qr_BOMBCHUSUPERBOMB) )
10855 {
10856 14 hp=-1000;
10857
10858
2/4
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 14 times.
14 if(wpn+dmisc3 > wEnemyWeapons && wpn+dmisc3 < wMax)
10859 {
10860
5/10
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 14 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 14 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 14 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 14 times.
✗ Branch 9 not taken.
14 weapon *ew=new weapon(x,y,z, wpn+dmisc3, 0, dmisc4, dir,-1,getUID());
10861 14 Ewpns.add(ew);
10862 14 ew->fakez = fakez;
10863
10864
2/4
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 14 times.
✗ Branch 3 not taken.
14 if(wpn==ewSBomb || wpn==ewBomb)
10865 {
10866 14 ew->step=0;
10867 14 ew->id=wpn+dmisc3;
10868 14 ew->misc=50;
10869 14 ew->clk=48;
10870 14 }
10871
10872 14 fired=true;
10873 14 }
10874 else
10875 {
10876 weapon *ew=new weapon(x,y,z, wpn, 0, dmisc4, dir,-1,getUID());
10877 Ewpns.add(ew);
10878 ew->fakez = fakez;
10879
10880 if(wpn==ewSBomb || wpn==ewBomb)
10881 {
10882 ew->step=0;
10883 ew->id=wpn;
10884 ew->misc=50;
10885 ew->clk=48;
10886 }
10887
10888 fired=true;
10889 }
10890 14 }
10891
10892 else
10893 {
10894 33 hp=-1000;
10895
10896 int32_t wpn2;
10897
2/4
✓ Branch 0 taken 33 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 33 times.
33 if(wpn+dmisc3 > wEnemyWeapons && wpn+dmisc3 < wMax)
10898 33 wpn2=wpn;
10899 else
10900 wpn2=wpn;
10901
10902
5/10
✓ Branch 0 taken 33 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 33 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 33 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 33 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 33 times.
✗ Branch 9 not taken.
33 weapon *ew=new weapon(x,y,z, wpn2, 0, dmisc4, dir,-1,getUID());
10903 33 Ewpns.add(ew);
10904 33 ew->fakez = fakez;
10905
10906
3/4
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 9 times.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
33 if(wpn2==ewSBomb || wpn2==ewBomb)
10907 {
10908 33 ew->step=0;
10909 33 ew->id=wpn2;
10910 33 ew->misc=50;
10911 33 ew->clk=48;
10912 33 }
10913
10914 33 fired=true;
10915 }
10916 47 }
10917 125430 }
10918
10919 981551 charge_attack();
10920 981551 break;
10921 }
10922 /*
10923 * Boomerang-throwers have a halt count of 1
10924 * Zols have a halt count of (zc_oldrand()&7)<<4
10925 * Gels have a halt count of ((zc_oldrand()&7)<<3)+2
10926 * Everything else has 48
10927 */
10928 else
10929 {
10930
2/2
✓ Branch 0 taken 568419 times.
✓ Branch 1 taken 11746261 times.
12314680 if(wpn==ewBrang) // Goriya
10931 {
10932 568419 halting_walk(rate,homing,0,hrate, 1);
10933 568419 }
10934
4/4
✓ Branch 0 taken 11602159 times.
✓ Branch 1 taken 144102 times.
✓ Branch 2 taken 4547551 times.
✓ Branch 3 taken 7054608 times.
11746261 else if(dmisc9==e9tNORMAL && wpn==0)
10935 {
10936
2/2
✓ Branch 0 taken 717973 times.
✓ Branch 1 taken 6336635 times.
7054608 if(dmisc2==e2tSPLITHIT) // Zol
10937 {
10938 717973 halting_walk(rate,homing,0,hrate,(zc_oldrand()&7)<<4);
10939 717973 }
10940
4/4
✓ Branch 0 taken 1753011 times.
✓ Branch 1 taken 4583624 times.
✓ Branch 2 taken 1537120 times.
✓ Branch 3 taken 215891 times.
6336635 else if(frate<=8 && starting_hp==1) // Gel
10941 {
10942 215891 halting_walk(rate,homing,0,hrate,((zc_oldrand()&7)<<3)+2);
10943 215891 }
10944 else // Other
10945 {
10946 6120744 halting_walk(rate,homing,0,hrate, 48);
10947 }
10948 7054608 }
10949 else // Other
10950 {
10951 4691653 halting_walk(rate,homing,0,hrate, 48);
10952 }
10953 }
10954
10955 //if not in midair, and Hero's swinging sword is nearby, jump.
10956 /*if (dmisc9==e9tZ3STALFOS && z==0 && (!(isSideViewGravity()) || !_walkflag(x,y+16,0))
10957 && Hero.getAttackClk()==5 && Hero.getAttack()==wSword && distance(x,y,Hero.getX(),Hero.getY())<32)
10958 {
10959 facehero(false);
10960 sclk=16+((dir^1)<<8);
10961 fall=-FEATHERJUMP;
10962 sfx(WAV_ZN1JUMP,pan(int32_t(x)));
10963 }*/
10964 12314680 break;
10965
10966 // Following cases are for just after creation-by-splitting.
10967 case 1:
10968
2/2
✓ Branch 0 taken 2473 times.
✓ Branch 1 taken 821 times.
3294 if(misc==1)
10969 {
10970 821 dir=up;
10971 821 step=8;
10972 821 }
10973
10974
2/2
✓ Branch 0 taken 790 times.
✓ Branch 1 taken 2504 times.
3294 if(misc<=2)
10975 {
10976 2504 move(step);
10977
10978
2/2
✓ Branch 0 taken 1992 times.
✓ Branch 1 taken 512 times.
2504 if(!canmove(dir,(zfix)0,0,false))
10979 512 dir=down;
10980 2504 }
10981
10982
2/2
✓ Branch 0 taken 2504 times.
✓ Branch 1 taken 790 times.
3294 if(misc==3)
10983 {
10984
2/2
✓ Branch 0 taken 287 times.
✓ Branch 1 taken 503 times.
790 if(canmove(right,(zfix)16,0,false))
10985 503 x+=16;
10986 790 }
10987
10988 3294 ++misc;
10989 3294 break;
10990
10991 case 2:
10992
2/2
✓ Branch 0 taken 44 times.
✓ Branch 1 taken 15 times.
59 if(misc==1)
10993 {
10994 15 dir=down;
10995 15 step=8;
10996 15 }
10997
10998
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 45 times.
59 if(misc<=2)
10999 {
11000 45 move(step);
11001 /*
11002 if(!canmove(dir,(zfix)0,0,false))
11003 dir=up;
11004 */
11005 45 }
11006
11007
2/2
✓ Branch 0 taken 45 times.
✓ Branch 1 taken 14 times.
59 if(misc==3)
11008 {
11009
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(canmove(left,(zfix)16,0,false))
11010 14 x-=16;
11011 14 }
11012
11013 59 ++misc;
11014 59 break;
11015
11016 default:
11017
2/2
✓ Branch 0 taken 80 times.
✓ Branch 1 taken 28 times.
108 if(misc==1)
11018 {
11019 28 dir=(zc_oldrand()%4);
11020 28 step=8;
11021 28 }
11022
11023
2/2
✓ Branch 0 taken 25 times.
✓ Branch 1 taken 83 times.
108 if(misc<=2)
11024 {
11025 83 move(step);
11026
11027
2/2
✓ Branch 0 taken 81 times.
✓ Branch 1 taken 2 times.
83 if(!canmove(dir,(zfix)0,0,false))
11028 2 dir=dir^1;
11029 83 }
11030
11031
2/2
✓ Branch 0 taken 83 times.
✓ Branch 1 taken 25 times.
108 if(misc==3)
11032 {
11033
3/4
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 17 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 8 times.
25 if(dir >= left && canmove(dir,(zfix)16,0,false))
11034 8 x+=(dir==left ? -16 : 16);
11035 25 }
11036
11037 108 ++misc;
11038 108 break;
11039 14095802 }
11040
11041
4/4
✓ Branch 0 taken 25272 times.
✓ Branch 1 taken 14909395 times.
✓ Branch 2 taken 24443 times.
✓ Branch 3 taken 829 times.
14934667 if(id>>12 && misc>=4) //recently spawned by a split enemy
11042 {
11043 829 id&=0xFFF;
11044 829 step = zslongToFix(dstep*100);
11045
11046
1/2
✓ Branch 0 taken 829 times.
✗ Branch 1 not taken.
829 if(x<32) x=32;
11047
11048
2/2
✓ Branch 0 taken 808 times.
✓ Branch 1 taken 21 times.
829 if(x>208) x=208;
11049
11050
2/2
✓ Branch 0 taken 805 times.
✓ Branch 1 taken 24 times.
829 if(y<32) y=32;
11051
11052
2/2
✓ Branch 0 taken 822 times.
✓ Branch 1 taken 7 times.
829 if(y>128) y=128;
11053
11054 829 misc=3;
11055 829 }
11056 14934667 }
11057 else
11058 {
11059 //sfx(wpnsfx(wpn),pan(int32_t(x)));
11060
1/2
✓ Branch 0 taken 432836 times.
✗ Branch 1 not taken.
432836 if(clk2>2) clk2--;
11061 }
11062
11063 // Fire Zol
11064
8/8
✓ Branch 0 taken 6100121 times.
✓ Branch 1 taken 9274589 times.
✓ Branch 2 taken 139281 times.
✓ Branch 3 taken 5960840 times.
✓ Branch 4 taken 1131 times.
✓ Branch 5 taken 138150 times.
✓ Branch 6 taken 1102 times.
✓ Branch 7 taken 29 times.
15374710 if(wpn && dmisc1==e1tEACHTILE && clk2==1 && !hclk)
11065 {
11066 1102 addEwpn(x,y,z,wpn,0,wdp,dir, getUID(), 0, fakez);
11067 1102 sfx(wpnsfx(wpn),pan(int32_t(x)));
11068
11069 1102 int32_t i=Ewpns.Count()-1;
11070 1102 weapon *ew = (weapon*)(Ewpns.spr(i));
11071
11072
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1102 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1102 if(wpn==ewFIRETRAIL && wpnsbuf[ewFIRETRAIL].frames>1)
11073 {
11074 ew->aframe=zc_oldrand()%wpnsbuf[ewFIRETRAIL].frames;
11075 if ( ew->do_animation ) ew->tile+=ew->aframe;
11076 }
11077 1102 }
11078 // Goriya
11079
14/16
✓ Branch 0 taken 1048873 times.
✓ Branch 1 taken 14324735 times.
✓ Branch 2 taken 468534 times.
✓ Branch 3 taken 580339 times.
✓ Branch 4 taken 456235 times.
✓ Branch 5 taken 12299 times.
✓ Branch 6 taken 423258 times.
✓ Branch 7 taken 32977 times.
✓ Branch 8 taken 423258 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 420517 times.
✓ Branch 11 taken 2741 times.
✓ Branch 12 taken 420517 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 414155 times.
✓ Branch 15 taken 6362 times.
15373608 else if(wpn==ewBrang && clk2==1 && sclk==0 && !stunclk && !frozenclock && !watch && wpn && !WeaponOut())
11080 {
11081 6362 misc=index+100;
11082
7/14
✓ Branch 0 taken 6362 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6362 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 6362 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 6362 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 6362 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 6362 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 6362 times.
✗ Branch 13 not taken.
6362 Ewpns.add(new weapon(x,y-fakez,z,wpn,misc,wdp,dir, -1,getUID(),false));
11083 6362 ((weapon*)Ewpns.spr(Ewpns.Count()-1))->dummy_bool[0]=false;
11084
11085
2/2
✓ Branch 0 taken 6105 times.
✓ Branch 1 taken 257 times.
6362 if(dmisc1==2)
11086 {
11087 257 int32_t ndir=dir;
11088
11089
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 251 times.
257 if(Hero.x-x==0)
11090 {
11091 6 ndir=(Hero.y+8<y)?up:down;
11092 6 }
11093 else //turn to face Hero
11094 {
11095 double _MSVC2022_tmp1, _MSVC2022_tmp2;
11096 251 double ddir=atan2_MSVC2022_FIX(double(y-(Hero.y)),double(Hero.x-x));
11097
11098
4/4
✓ Branch 0 taken 58 times.
✓ Branch 1 taken 193 times.
✓ Branch 2 taken 45 times.
✓ Branch 3 taken 13 times.
251 if((ddir<=(((-2)*PI)/8))&&(ddir>(((-6)*PI)/8)))
11099 {
11100 13 ndir=down;
11101 13 }
11102
4/4
✓ Branch 0 taken 113 times.
✓ Branch 1 taken 125 times.
✓ Branch 2 taken 45 times.
✓ Branch 3 taken 68 times.
238 else if((ddir<=(((2)*PI)/8))&&(ddir>(((-2)*PI)/8)))
11103 {
11104 68 ndir=right;
11105 68 }
11106
4/4
✓ Branch 0 taken 93 times.
✓ Branch 1 taken 77 times.
✓ Branch 2 taken 45 times.
✓ Branch 3 taken 48 times.
170 else if((ddir<=(((6)*PI)/8))&&(ddir>(((2)*PI)/8)))
11107 {
11108 48 ndir=up;
11109 48 }
11110 else
11111 {
11112 122 ndir=left;
11113 }
11114 }
11115
11116 257 ((weapon*)Ewpns.spr(Ewpns.Count()-1))->dummy_bool[0]=true;
11117
11118
2/2
✓ Branch 0 taken 34 times.
✓ Branch 1 taken 223 times.
257 if(canmove(ndir,false))
11119 {
11120 223 dir=ndir;
11121 223 }
11122 257 }
11123 6362 }
11124
15/16
✓ Branch 0 taken 15308366 times.
✓ Branch 1 taken 58880 times.
✓ Branch 2 taken 221192 times.
✓ Branch 3 taken 15146054 times.
✓ Branch 4 taken 195074 times.
✓ Branch 5 taken 26118 times.
✓ Branch 6 taken 170182 times.
✓ Branch 7 taken 24892 times.
✓ Branch 8 taken 168798 times.
✓ Branch 9 taken 1384 times.
✓ Branch 10 taken 153698 times.
✓ Branch 11 taken 15100 times.
✓ Branch 12 taken 153698 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 944 times.
✓ Branch 15 taken 152754 times.
15367246 else if((clk2==16 || dmisc1==e1tCONSTANT) && dmisc1!=e1tEACHTILE && wpn && wpn!=ewBrang && sclk==0 && !stunclk && !frozenclock && !watch)
11125
3/3
✓ Branch 0 taken 26116 times.
✓ Branch 1 taken 125732 times.
✓ Branch 2 taken 906 times.
152754 switch(dmisc1)
11126 {
11127 case e1tCONSTANT: //Deathnut
11128 {
11129 // Overloading clk5 (Like Like clock) to avoid making another clock just for this attack...
11130
2/2
✓ Branch 0 taken 123149 times.
✓ Branch 1 taken 2583 times.
125732 if(clk5>64)
11131 {
11132 2583 clk5=0;
11133 2583 fired=false;
11134 2583 }
11135
11136 125732 clk5+=(zc_oldrand()&3);
11137
11138
4/4
✓ Branch 0 taken 76714 times.
✓ Branch 1 taken 49018 times.
✓ Branch 2 taken 25645 times.
✓ Branch 3 taken 51069 times.
125732 if((clk5>24)&&(clk5<52))
11139 {
11140
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 51069 times.
51069 if ( do_animation )tile+=20; //firing
11141
11142
4/4
✓ Branch 0 taken 27958 times.
✓ Branch 1 taken 23111 times.
✓ Branch 2 taken 25131 times.
✓ Branch 3 taken 2827 times.
51069 if(!fired&&(clk5>=38))
11143 {
11144
5/10
✓ Branch 0 taken 2827 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2827 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2827 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 2827 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 2827 times.
✗ Branch 9 not taken.
2827 Ewpns.add(new weapon(x,y,z, wpn, 0, wdp, dir, -1,getUID(),false));
11145 2827 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
11146 2827 sfx(wpnsfx(wpn),pan(int32_t(x)));
11147 2827 fired=true;
11148 2827 }
11149 51069 }
11150
11151 125732 break;
11152 }
11153
11154 case e1tFIREOCTO: //Fire Octo
11155 906 timer=zc_oldrand()%50+50;
11156 906 break;
11157
11158 default:
11159 26116 FireWeapon();
11160 26116 break;
11161 152754 }
11162
11163 /* Fire again if:
11164 * - clk2 about to run out
11165 * - not already double-firing (dmisc1 is 1)
11166 * - not carrying Hero
11167 * - one in 0xF chance
11168 */
11169
8/10
✓ Branch 0 taken 524932 times.
✓ Branch 1 taken 14849778 times.
✓ Branch 2 taken 4002 times.
✓ Branch 3 taken 520930 times.
✓ Branch 4 taken 4002 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 4002 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 3751 times.
✓ Branch 9 taken 251 times.
15374710 if(clk2==1 && (multishot < dmisc6) && dmisc1 != e1tEACHTILE && !hashero && !(zc_oldrand()&15))
11170 {
11171 #if 1
11172 251 newdir(rate, homing, grumble);
11173 #else
11174 dir^=2;
11175 #endif
11176 251 clk2=28;
11177 251 ++multishot;
11178 251 }
11179
11180
2/2
✓ Branch 0 taken 3492313 times.
✓ Branch 1 taken 11882397 times.
15374710 if(clk2==0)
11181 {
11182 11882397 multishot = 0;
11183 11882397 }
11184
11185
2/2
✓ Branch 0 taken 15310400 times.
✓ Branch 1 taken 64310 times.
15374710 if(timer) //Fire Octo
11186 {
11187 64310 clk2=15; //this keeps the octo in place until he's done firing
11188
11189
2/2
✓ Branch 0 taken 48558 times.
✓ Branch 1 taken 15752 times.
64310 if(!(timer%4))
11190 {
11191 15752 FireBreath(false);
11192 15752 }
11193
11194 64310 --timer;
11195 64310 }
11196
11197
2/2
✓ Branch 0 taken 15125317 times.
✓ Branch 1 taken 249393 times.
15374710 if(dmisc2==e2tTRIBBLE)
11198 249393 ++clk4;
11199
11200
7/10
✓ Branch 0 taken 4480 times.
✓ Branch 1 taken 15370230 times.
✓ Branch 2 taken 693 times.
✓ Branch 3 taken 15374017 times.
✓ Branch 4 taken 693 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 693 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 693 times.
15374710 if(clk4==(dmisc5 ? dmisc5 : 256) && (dmisc2==e2tTRIBBLE) && dmisc3 && dmisc4)
11201 {
11202 693 int32_t kids = guys.Count();
11203 693 int32_t id2=dmisc3;
11204
11205
2/2
✓ Branch 0 taken 693 times.
✓ Branch 1 taken 693 times.
1386 for(int32_t i=0; i<dmisc4; i++)
11206 {
11207
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 693 times.
693 if(addenemy(x,y,id2,-24))
11208 {
11209
1/2
✓ Branch 0 taken 693 times.
✗ Branch 1 not taken.
693 if(itemguy) // Hand down the carried item
11210 {
11211 guycarryingitem = guys.Count()-1;
11212 ((enemy*)guys.spr(guycarryingitem))->itemguy = true;
11213 itemguy = false;
11214 }
11215
11216 693 ((enemy*)guys.spr(kids+i))->count_enemy = false;
11217 693 }
11218 693 }
11219
11220
1/2
✓ Branch 0 taken 693 times.
✗ Branch 1 not taken.
693 if(hashero)
11221 {
11222 Hero.setEaten(0);
11223 hashero=false;
11224 }
11225
11226 693 stop_bgsfx(index);
11227 693 return true;
11228 }
11229
11230 15374017 return enemy::animate(index);
11231 15797387 }
11232
11233 16192980 void eStalfos::draw(BITMAP *dest)
11234 {
11235 /*if ((dmisc9==e9tLEEVER || dmisc9==e9tZ3LEEVER) && misc<=0) //Submerged
11236 {
11237 clk4--; //Kludge
11238 return;
11239 }*/
11240
11241 /*if ((dmisc9==e9tLEEVER || dmisc9==e9tZ3LEEVER) && misc>1)
11242 {
11243 cs = dcset;
11244 }*/
11245 16192980 update_enemy_frame();
11246
11247
7/8
✓ Branch 0 taken 16192554 times.
✓ Branch 1 taken 426 times.
✓ Branch 2 taken 16192554 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 86951 times.
✓ Branch 5 taken 16105603 times.
✓ Branch 6 taken 75836 times.
✓ Branch 7 taken 11115 times.
16192980 if(!fallclk&&!drownclk&&(dmisc2==e2tBOMBCHU)&&dashing)
11248 {
11249
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11115 times.
11115 if ( do_animation )tile+=20;
11250 11115 }
11251
11252 16192980 enemy::draw(dest);
11253 16192980 }
11254
11255 7492339 void eStalfos::drawshadow(BITMAP *dest, bool translucent)
11256 {
11257 7492339 int32_t tempy=yofs;
11258
11259 /*
11260 if (clk6 && dir>=left && !get_qr(qr_ENEMIESZAXIS)) {
11261 flip = 0;
11262 int32_t f2=get_qr(qr_NEWENEMYTILES)?
11263 (clk/(frate/4)):((clk>=(frate>>1))?1:0);
11264 shadowtile = wpnsbuf[spr_shadow].tile+f2;
11265 yofs+=(((int32_t)y+17)&0xF0)-y;
11266 yofs+=8;
11267 }
11268 */
11269
4/4
✓ Branch 0 taken 7276921 times.
✓ Branch 1 taken 215418 times.
✓ Branch 2 taken 7180720 times.
✓ Branch 3 taken 311619 times.
7492339 if((dmisc9 == e9tPOLSVOICE || dmisc9==e9tVIRE) && !get_qr(qr_ENEMIESZAXIS))
11270 {
11271 311619 flip = 0;
11272 311619 int32_t fdiv = frate/4;
11273
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 311619 times.
311619 int32_t efrate = fdiv == 0 ? 0 : clk/fdiv;
11274
11275
1/2
✓ Branch 0 taken 311619 times.
✗ Branch 1 not taken.
311619 int32_t f2=get_qr(qr_NEWENEMYTILES)?
11276 311619 efrate:((clk>=(frate>>1))?1:0);
11277 311619 shadowtile = wpnsbuf[spr_shadow].tile;
11278
11279
1/2
✓ Branch 0 taken 311619 times.
✗ Branch 1 not taken.
311619 if(get_qr(qr_NEWENEMYTILES))
11280 {
11281 311619 shadowtile+=f2;
11282 311619 }
11283 else
11284 {
11285 shadowtile+=f2?1:0;
11286 }
11287
11288 311619 yofs+=shadowdistance;
11289 311619 yofs+=8;
11290 311619 }
11291
4/4
✓ Branch 0 taken 7276921 times.
✓ Branch 1 taken 215418 times.
✓ Branch 2 taken 7489304 times.
✓ Branch 3 taken 3035 times.
7492339 if((dmisc9 == e9tPOLSVOICE || dmisc9==e9tVIRE) && !get_qr(qr_POLVIRE_NO_SHADOW))
11292 {
11293 3035 flip = 0;
11294 3035 int32_t fdiv = frate/4;
11295
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3035 times.
3035 int32_t efrate = fdiv == 0 ? 0 : clk/fdiv;
11296
11297
1/2
✓ Branch 0 taken 3035 times.
✗ Branch 1 not taken.
3035 int32_t f2=get_qr(qr_NEWENEMYTILES)?
11298 3035 efrate:((clk>=(frate>>1))?1:0);
11299 3035 shadowtile = wpnsbuf[spr_shadow].tile;
11300
11301
1/2
✓ Branch 0 taken 3035 times.
✗ Branch 1 not taken.
3035 if(get_qr(qr_NEWENEMYTILES))
11302 {
11303 3035 shadowtile+=f2;
11304 3035 }
11305 else
11306 {
11307 shadowtile+=f2?1:0;
11308 }
11309 3035 }
11310
2/2
✓ Branch 0 taken 5496 times.
✓ Branch 1 taken 7486843 times.
7492339 if(!shadow_overpit(this))
11311 7486843 enemy::drawshadow(dest, translucent);
11312 7492339 yofs=tempy;
11313 7492339 }
11314
11315 157613 int32_t eStalfos::takehit(weapon *w, weapon* realweap)
11316 {
11317 157613 int32_t wpnId = w->id;
11318 157613 int32_t wpnDir = w->dir;
11319
11320
4/4
✓ Branch 0 taken 1418 times.
✓ Branch 1 taken 156195 times.
✓ Branch 2 taken 609 times.
✓ Branch 3 taken 809 times.
157613 if(wpnId==wHammer && shield && (flags & guy_bkshield)
11321
6/8
✓ Branch 0 taken 385 times.
✓ Branch 1 taken 224 times.
✓ Branch 2 taken 385 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 265 times.
✓ Branch 5 taken 120 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 120 times.
609 && ((flags&guy_shield_front && wpnDir==(dir^down)) || (flags&guy_shield_back && wpnDir==(dir^up))
11322
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 120 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 120 times.
120 || (flags&guy_shield_left && wpnDir==(dir^left)) || (flags&guy_shield_right && wpnDir==(dir^right))))
11323 {
11324 265 shield = false;
11325 265 flags &= ~(guy_shield_left|guy_shield_right|guy_shield_back|guy_shield_front);
11326
11327
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 243 times.
265 if(get_qr(qr_BRKNSHLDTILES))
11328 243 o_tile=s_tile;
11329 265 }
11330
11331 157613 int32_t ret = enemy::takehit(w,realweap);
11332
11333
4/4
✓ Branch 0 taken 22309 times.
✓ Branch 1 taken 135304 times.
✓ Branch 2 taken 20558 times.
✓ Branch 3 taken 1751 times.
157613 if(sclk && dmisc2==e2tSPLITHIT)
11334 1751 sclk+=128; //Fuck these arbitrary values with no explanation. Fuck vires, too. -Z
11335
11336 157613 return ret;
11337 }
11338
11339 981551 void eStalfos::charge_attack()
11340 {
11341
2/2
✓ Branch 0 taken 6715 times.
✓ Branch 1 taken 974836 times.
981551 if(slide())
11342 6715 return;
11343
11344
10/12
✓ Branch 0 taken 974836 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 972432 times.
✓ Branch 3 taken 2404 times.
✓ Branch 4 taken 942919 times.
✓ Branch 5 taken 29513 times.
✓ Branch 6 taken 921366 times.
✓ Branch 7 taken 21553 times.
✓ Branch 8 taken 915743 times.
✓ Branch 9 taken 5623 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 915743 times.
974836 if(clk<0 || dir<0 || stunclk || watch || ceiling || frozenclock )
11345 59093 return;
11346
11347
2/2
✓ Branch 0 taken 37390 times.
✓ Branch 1 taken 878353 times.
915743 if(clk3<=0)
11348 {
11349 37390 fix_coords(true);
11350
11351
2/2
✓ Branch 0 taken 10009 times.
✓ Branch 1 taken 27381 times.
37390 if(!dashing)
11352 {
11353 27381 int32_t ldir = lined_up(7,false);
11354
11355
4/4
✓ Branch 0 taken 3087 times.
✓ Branch 1 taken 24294 times.
✓ Branch 2 taken 452 times.
✓ Branch 3 taken 2635 times.
27381 if(ldir!=-1 && canmove(ldir,false))
11356 {
11357 2635 dir=ldir;
11358 2635 dashing=true;
11359
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2635 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2635 if(dmisc10<=0 || replay_version_check(0,33))
11360 2635 step=zslongToFix(dstep*100)+1;
11361 else
11362 step=zslongToFix(dmisc10*100);
11363 2635 }
11364 24746 else newdir(4,0,0);
11365 27381 }
11366
11367
2/2
✓ Branch 0 taken 35948 times.
✓ Branch 1 taken 1442 times.
37390 if(!canmove(dir,false))
11368 {
11369 1442 step=zslongToFix(dstep*100);
11370 1442 newdir();
11371 1442 dashing=false;
11372 1442 }
11373
11374 37390 zfix div = step;
11375
11376
1/2
✓ Branch 0 taken 37390 times.
✗ Branch 1 not taken.
37390 if(div == 0)
11377 div = 1;
11378
11379 37390 clk3=(int32_t)(16.0/div);
11380 37390 return;
11381 }
11382
11383 878353 move(step);
11384 878353 --clk3;
11385 981551 }
11386
11387 796110 void eStalfos::vire_hop()
11388 {
11389 //if ( sclk > 0 ) return; //Don't hop during knockback.
11390
11391 // if(dmisc9!=e9tPOLSVOICE)
11392 // {
11393 // //if( slide() /*sclk!=0*/ && dmisc2==e2tSPLIT) //Vires with split on hit, only! -Z
11394 // if( sclk!=0 && dmisc2==e2tSPLIT) //Vires with split on hit, only! -Z
11395 // return; //the enemy should split if it is sliding!
11396 // //else sclk=0; //might need this here, too. -Z
11397 // }
11398
2/2
✓ Branch 0 taken 379034 times.
✓ Branch 1 taken 417076 times.
796110 if(dmisc9!=e9tPOLSVOICE)
11399 {
11400
2/2
✓ Branch 0 taken 372449 times.
✓ Branch 1 taken 6585 times.
379034 if(sclk!=0)
11401 {
11402
2/2
✓ Branch 0 taken 2742 times.
✓ Branch 1 taken 3843 times.
6585 if (dmisc2==e2tSPLITHIT) return;
11403 //return;
11404 3843 }
11405 376292 }
11406 417076 else sclk=0;
11407
11408
8/12
✓ Branch 0 taken 793368 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 793368 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 777885 times.
✓ Branch 5 taken 15483 times.
✓ Branch 6 taken 761476 times.
✓ Branch 7 taken 16409 times.
✓ Branch 8 taken 761476 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 761476 times.
793368 if(clk<0 || dying || stunclk || watch || ceiling || frozenclock)
11409 31892 return;
11410
11411 761476 int32_t jump_width = (dmisc9==e9tPOLSVOICE) ? 2 : 1;
11412 761476 int32_t jump_height = (dmisc9==e9tPOLSVOICE) ? 27 : 16;
11413
11414 761476 y=floor_y;
11415
11416
2/2
✓ Branch 0 taken 735218 times.
✓ Branch 1 taken 26258 times.
761476 if(clk3<=0)
11417 {
11418 26258 fix_coords();
11419
11420 //z=0;
11421 //if we're not in the middle of a jump or if we can't complete the current jump in the current direction
11422 //if(clk2<=0 || !canmove(dir,(zfix)1,spw_floater,false) || (isSideViewGravity() && isOnSideviewPlatform()))
11423
9/10
✓ Branch 0 taken 4922 times.
✓ Branch 1 taken 21336 times.
✓ Branch 2 taken 4320 times.
✓ Branch 3 taken 602 times.
✓ Branch 4 taken 94 times.
✓ Branch 5 taken 4226 times.
✓ Branch 6 taken 42 times.
✓ Branch 7 taken 52 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 42 times.
26258 if(clk2<=0 || !canmove(dir,(zfix)1,spw_floater,false) || (isSideViewGravity() && (isOnSideviewPlatform() || !(moveflags & move_obeys_grav)))) //Vires in old quests
11424 22032 newdir(rate,homing,dmisc9==e9tPOLSVOICE ? spw_floater : spw_none);
11425
11426
2/2
✓ Branch 0 taken 4922 times.
✓ Branch 1 taken 21336 times.
26258 if(clk2<=0)
11427 {
11428 //z=0;
11429
6/6
✓ Branch 0 taken 19015 times.
✓ Branch 1 taken 2321 times.
✓ Branch 2 taken 18569 times.
✓ Branch 3 taken 446 times.
✓ Branch 4 taken 14491 times.
✓ Branch 5 taken 4078 times.
21336 if(!canmove(dir,(zfix)2,spw_none,false) || m_walkflag(x,y,spw_none, dir) || (zc_oldrand()&15)>=hrate)
11430 {
11431
11432
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17258 times.
17258 clk2=(wpn==ewBrang ? 1 : int32_t((16.0*jump_width)/step.getFloat()));
11433 /*if (dmisc9==e9tPOLSVOICE )
11434 {
11435 zprint2("polsvoice jump_width is: %d\n", jump_width);
11436 zprint2("polsvoice raw step is: %d\n", step);
11437 zprint2("polsvoice step.getInt() is: %d\n", step.getInt());
11438 zprint2("setting clk2 on polsvoice to: %d\n", clk2);
11439 }
11440 else
11441 {
11442 zprint2("vire jump_width is: %d\n", jump_width);
11443 zprint2("vire raw step is: %d\n", step);
11444 zprint2("vire step.getInt() is: %d\n", step.getInt());
11445 zprint2("setting clk2 on vire to: %d\n", clk2);
11446 }
11447 */
11448 17258 }
11449 21336 }
11450
11451
4/4
✓ Branch 0 taken 12099 times.
✓ Branch 1 taken 14159 times.
✓ Branch 2 taken 5069 times.
✓ Branch 3 taken 7030 times.
26258 if(dmisc9!=e9tPOLSVOICE && dir>=left) //if we're moving left or right
11452 {
11453 7030 clk2=int32_t((16.0*jump_width)/step.getFloat());
11454 7030 }
11455
11456 26258 clk3=int32_t(16.0/step.getFloat());
11457 26258 }
11458
11459 761476 --clk3;
11460
11461
3/4
✓ Branch 0 taken 361067 times.
✓ Branch 1 taken 400409 times.
✓ Branch 2 taken 361067 times.
✗ Branch 3 not taken.
761476 if(dmisc9==e9tPOLSVOICE || clk2>0)
11462 761476 move(step);
11463
11464 761476 floor_y=y;
11465 761476 clk2--;
11466
11467 //if we're in the middle of a jump
11468
6/6
✓ Branch 0 taken 624929 times.
✓ Branch 1 taken 136547 times.
✓ Branch 2 taken 257704 times.
✓ Branch 3 taken 367225 times.
✓ Branch 4 taken 110653 times.
✓ Branch 5 taken 147051 times.
761476 if(clk2>0 && (dir>=left || dmisc9==e9tPOLSVOICE))
11469 {
11470 477878 int32_t h = fixtoi(fixsin(itofix(clk2*128*step/(16*jump_width)))*jump_height);
11471
11472
4/4
✓ Branch 0 taken 99298 times.
✓ Branch 1 taken 378580 times.
✓ Branch 2 taken 6151 times.
✓ Branch 3 taken 93147 times.
477878 if(get_qr(qr_ENEMIESZAXIS) && !(isSideViewGravity()))
11473 {
11474
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 93147 times.
93147 if (moveflags & move_use_fake_z) fakez=h;
11475 93147 else z=h;
11476 93147 }
11477 else
11478 {
11479 //y+=fixtoi(fixsin(itofix((clk2+1)*128*step/(16*jump_width)))*jump_height);
11480 //y-=h;
11481 384731 y=floor_y-h;
11482 384731 shadowdistance=h;
11483 }
11484 477878 }
11485 else
11486 283598 shadowdistance = 0;
11487 796110 }
11488
11489 138 void eStalfos::eathero()
11490 {
11491
5/8
✓ Branch 0 taken 70 times.
✓ Branch 1 taken 68 times.
✓ Branch 2 taken 70 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 70 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 70 times.
138 if(!hashero && Hero.getEaten()==0 && Hero.getAction() != hopping && Hero.getAction() != swimming)
11492 {
11493 70 hashero=true;
11494 70 y=floor_y;
11495 70 z=0;
11496
11497
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 70 times.
70 if(Hero.isSwimming())
11498 {
11499 Hero.setX(x);
11500 Hero.setY(y);
11501 }
11502 else
11503 {
11504 70 x=Hero.getX();
11505 70 y=Hero.getY();
11506 }
11507
11508 70 clk2=0;
11509 70 }
11510 138 }
11511
11512 1469390 bool eStalfos::WeaponOut()
11513 {
11514
2/2
✓ Branch 0 taken 2400579 times.
✓ Branch 1 taken 622399 times.
3022978 for(int32_t i=0; i<Ewpns.Count(); i++)
11515 {
11516
3/4
✓ Branch 0 taken 846991 times.
✓ Branch 1 taken 1553588 times.
✓ Branch 2 taken 846991 times.
✗ Branch 3 not taken.
2400579 if(((weapon*)Ewpns.spr(i))->parentid==getUID() && Ewpns.spr(i)->id==ewBrang)
11517 {
11518 846991 return true;
11519 }
11520
11521 /*if (bgsfx > 0 && guys.idCount(id) < 2) // count self
11522 stop_sfx(bgsfx);
11523 */
11524 1553588 }
11525
11526 622399 return false;
11527 1469390 }
11528
11529 352672 void eStalfos::KillWeapon()
11530 {
11531
2/2
✓ Branch 0 taken 352672 times.
✓ Branch 1 taken 293384 times.
646056 for(int32_t i=0; i<Ewpns.Count(); i++)
11532 {
11533
4/4
✓ Branch 0 taken 245286 times.
✓ Branch 1 taken 48098 times.
✓ Branch 2 taken 244476 times.
✓ Branch 3 taken 810 times.
293384 if(((weapon*)Ewpns.spr(i))->type==misc && Ewpns.spr(i)->id==ewBrang)
11534 {
11535 //only kill this Goriya's boomerang -DD
11536
2/2
✓ Branch 0 taken 399 times.
✓ Branch 1 taken 411 times.
810 if(((weapon *)Ewpns.spr(i))->parentid == getUID())
11537 {
11538 411 Ewpns.del(i);
11539 411 }
11540 810 }
11541 293384 }
11542
11543
4/4
✓ Branch 0 taken 26052 times.
✓ Branch 1 taken 326620 times.
✓ Branch 2 taken 14170 times.
✓ Branch 3 taken 11882 times.
352672 if(wpn==ewBrang && !Ewpns.idCount(ewBrang))
11544 {
11545 14170 stop_sfx(WAV_BRANG);
11546 14170 }
11547 352672 }
11548
11549 void eStalfos::break_shield()
11550 {
11551 if(!shield)
11552 return;
11553
11554 flags&=~(guy_shield_front | guy_shield_back | guy_shield_left | guy_shield_right);
11555 shield=false;
11556
11557 if(get_qr(qr_BRKNSHLDTILES))
11558 o_tile=s_tile;
11559 }
11560
11561 13582 eKeese::eKeese(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
11562 13582 {
11563
1/2
✓ Branch 0 taken 13582 times.
✗ Branch 1 not taken.
13582 dir=(zc_oldrand()&7)+8;
11564
1/2
✓ Branch 0 taken 13582 times.
✗ Branch 1 not taken.
13582 step=0;
11565 13582 movestatus=1;
11566
3/4
✓ Branch 0 taken 10458 times.
✓ Branch 1 taken 3124 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 10458 times.
13582 if (dmisc1 != 1 && dmisc19 > 0)
11567 {
11568 step = dmisc19/100.0;
11569 movestatus = 1;
11570 }
11571
1/2
✓ Branch 0 taken 13582 times.
✗ Branch 1 not taken.
13582 if (dmisc1 == 2) movestatus=2;
11572 13582 c=0;
11573 13582 clk4=0;
11574 //nets;
11575
1/2
✓ Branch 0 taken 13582 times.
✗ Branch 1 not taken.
13582 init_size_flags();
11576 13582 dummy_int[1]=0;
11577 13582 }
11578
11579 3505411 bool eKeese::animate(int32_t index)
11580 {
11581
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3505411 times.
3505411 if(switch_hooked) return enemy::animate(index);
11582
2/4
✓ Branch 0 taken 3505411 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 3505411 times.
3505411 if(fallclk||drownclk) return enemy::animate(index);
11583
2/2
✓ Branch 0 taken 124201 times.
✓ Branch 1 taken 3381210 times.
3505411 if(dying)
11584 124201 return Dead(index);
11585
11586
2/2
✓ Branch 0 taken 3355205 times.
✓ Branch 1 taken 26005 times.
3381210 if(clk==0)
11587 {
11588 26005 removearmos(x,y,ffcactivated);
11589 26005 }
11590
11591
2/2
✓ Branch 0 taken 1025042 times.
✓ Branch 1 taken 2356168 times.
3381210 if(dmisc1 == 1) //Walk style. 0 is keese, 1 is bat.
11592 {
11593 1025042 floater_walk(rate,hrate,dstep/100,(zfix)0,10,dmisc16,dmisc17);
11594 1025042 }
11595 else
11596 {
11597
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2356168 times.
2356168 if (dmisc18) floater_walk(rate,hrate,dstep/100,dmisc18/100.0,-1,dmisc16,dmisc17);
11598 2356168 else floater_walk(rate,hrate,dstep/100,dstep/1000,10,dmisc16,dmisc17);
11599 }
11600
11601
2/2
✓ Branch 0 taken 120338 times.
✓ Branch 1 taken 3260872 times.
3381210 if(dmisc2 == e2tKEESETRIB)
11602 {
11603
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 120338 times.
✓ Branch 2 taken 120147 times.
✓ Branch 3 taken 191 times.
120338 if(++clk4==(dmisc20>0?dmisc20:256))
11604 {
11605
2/2
✓ Branch 0 taken 86 times.
✓ Branch 1 taken 105 times.
191 if(!m_walkflag(x,y,0, dir))
11606 {
11607 105 int32_t kids = guys.Count();
11608 105 bool success = false;
11609 105 int32_t id2=dmisc3;
11610 105 success = 0 != addenemy((zfix)x,(zfix)y,id2,-24);
11611
11612
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 105 times.
105 if(success)
11613 {
11614
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 if(itemguy) // Hand down the carried item
11615 {
11616 guycarryingitem = guys.Count()-1;
11617 ((enemy*)guys.spr(guycarryingitem))->itemguy = true;
11618 itemguy = false;
11619 }
11620
11621 105 ((enemy*)guys.spr(kids))->count_enemy = count_enemy;
11622 105 }
11623
11624 105 stop_bgsfx(index);
11625 105 return true;
11626 }
11627 else
11628 {
11629 86 clk4=0;
11630 }
11631 86 }
11632 120233 }
11633 // Keese Tribbles stay on the ground, so there's no problem when they transform.
11634
3/4
✓ Branch 0 taken 845879 times.
✓ Branch 1 taken 2414993 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 845879 times.
3260872 else if(get_qr(qr_ENEMIESZAXIS) && !(isSideViewGravity()))
11635 {
11636
2/2
✓ Branch 0 taken 687068 times.
✓ Branch 1 taken 158811 times.
845879 if (get_qr(qr_OLD_KEESE_Z_AXIS))
11637 {
11638
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 687068 times.
687068 if (moveflags & move_use_fake_z)
11639 {
11640 fakez=int32_t(step/zslongToFix(dstep*100));
11641 // Some variance in keese flight heights when away from Hero
11642 fakez+=int32_t(step*zc_max(0_zf,(distance(x,y,HeroX(),HeroY())-128)/10));
11643
11644 }
11645 else
11646 {
11647 687068 z=int32_t(step/zslongToFix(dstep*100));
11648 // Some variance in keese flight heights when away from Hero
11649
2/2
✓ Branch 0 taken 503635 times.
✓ Branch 1 taken 183433 times.
687068 z+=int32_t(step*zc_max(0_zf,(distance(x,y,HeroX(),HeroY())-128)/10));
11650 }
11651 687068 }
11652 else
11653 {
11654
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 158811 times.
158811 if (moveflags & move_use_fake_z)
11655 {
11656 fakez=int32_t(step/zslongToFix(dstep*100));
11657 // Some variance in keese flight heights when away from Hero
11658 fakez+=int32_t(step*zc_max(0_zf,(distance(x,y,HeroX(),HeroY())-40)/4));
11659
11660 }
11661 else
11662 {
11663 158811 z=int32_t(step/zslongToFix(dstep*100));
11664 // Some variance in keese flight heights when away from Hero
11665
2/2
✓ Branch 0 taken 16841 times.
✓ Branch 1 taken 141970 times.
158811 z+=int32_t(step*zc_max(0_zf,(distance(x,y,HeroX(),HeroY())-40)/4));
11666 }
11667 }
11668 845879 }
11669
11670 3381105 return enemy::animate(index);
11671 3505411 }
11672
11673 2056065 void eKeese::drawshadow(BITMAP *dest, bool translucent)
11674 {
11675 2056065 int32_t tempy=yofs;
11676 2056065 flip = 0;
11677 2056065 shadowtile = wpnsbuf[spr_shadow].tile+posframe;
11678
11679
2/2
✓ Branch 0 taken 653085 times.
✓ Branch 1 taken 1402980 times.
2056065 yofs+=zc_min(int32_t(step/zslongToFix(dstep*10)), 8);
11680
2/2
✓ Branch 0 taken 690563 times.
✓ Branch 1 taken 1365502 times.
2056065 if(!get_qr(qr_ENEMIESZAXIS))
11681 {
11682 1365502 yofs+=int32_t(step/zslongToFix(dstep*10));
11683 1365502 }
11684
11685
6/6
✓ Branch 0 taken 2035375 times.
✓ Branch 1 taken 20690 times.
✓ Branch 2 taken 676820 times.
✓ Branch 3 taken 1358555 times.
✓ Branch 4 taken 661452 times.
✓ Branch 5 taken 15368 times.
2056065 if(!shadow_overpit(this) && (!get_qr(qr_ENEMIESZAXIS) || step > 0))
11686 2020007 enemy::drawshadow(dest, translucent);
11687 2056065 yofs=tempy;
11688 2056065 }
11689
11690 7885431 void eKeese::draw(BITMAP *dest)
11691 {
11692 7885431 update_enemy_frame();
11693 7885431 enemy::draw(dest);
11694 7885431 }
11695
11696 13582 void eKeese::init_size_flags()
11697 {
11698 13582 SIZEflags = d->SIZEflags;
11699
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13582 times.
13582 if (!(SIZEflags & OVERRIDE_HIT_X_OFFSET)) hxofs = 2;
11700
1/2
✓ Branch 0 taken 13582 times.
✗ Branch 1 not taken.
13582 if ((SIZEflags & OVERRIDE_HIT_X_OFFSET) != 0) hxofs = d->hxofs;
11701
11702
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13582 times.
13582 if (!(SIZEflags & OVERRIDE_HIT_WIDTH)) hit_width = 12;
11703
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 13582 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
13582 if (((SIZEflags & OVERRIDE_HIT_WIDTH) != 0) && d->hxsz >= 0) hit_width = d->hxsz;
11704
11705
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13582 times.
13582 if (!(SIZEflags & OVERRIDE_HIT_Y_OFFSET)) hyofs = 4;
11706
1/2
✓ Branch 0 taken 13582 times.
✗ Branch 1 not taken.
13582 if ((SIZEflags & OVERRIDE_HIT_Y_OFFSET) != 0) hyofs = d->hyofs;
11707
11708
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13582 times.
13582 if (!(SIZEflags & OVERRIDE_HIT_HEIGHT)) hit_height = 8;
11709
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 13582 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
13582 if (((SIZEflags & OVERRIDE_HIT_HEIGHT) != 0) && d->hysz >= 0) hit_height = d->hysz;
11710
11711
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 13582 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
13582 if (((SIZEflags & OVERRIDE_TILE_WIDTH) != 0) && d->txsz > 0) { txsz = d->txsz; if (txsz > 1) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
11712 // al_trace("Enemy txsz:%i\n", txsz);
11713
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 13582 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
13582 if (((SIZEflags & OVERRIDE_TILE_HEIGHT) != 0) && d->tysz > 0) { tysz = d->tysz; if (tysz > 1) extend = 3; }
11714
11715
11716
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 13582 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
13582 if (((SIZEflags & OVERRIDE_HIT_Z_HEIGHT) != 0) && d->hzsz >= 0) hzsz = d->hzsz;
11717
11718
1/2
✓ Branch 0 taken 13582 times.
✗ Branch 1 not taken.
13582 if ((SIZEflags & OVERRIDE_DRAW_X_OFFSET) != 0) xofs = (int32_t)d->xofs;
11719
1/2
✓ Branch 0 taken 13582 times.
✗ Branch 1 not taken.
13582 if ((SIZEflags & OVERRIDE_DRAW_Y_OFFSET) != 0)
11720 {
11721 yofs = (int32_t)d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
11722 yofs += (get_qr(qr_OLD_DRAWOFFSET) ? playing_field_offset : original_playing_field_offset); //this offset fixes yofs not plaing properly. -Z
11723 }
11724
11725
1/2
✓ Branch 0 taken 13582 times.
✗ Branch 1 not taken.
13582 if ((SIZEflags & OVERRIDE_DRAW_Z_OFFSET) != 0) zofs = (int32_t)d->zofs;
11726 13582 }
11727
11728 20081 void eWizzrobe::submerge(bool set)
11729 {
11730
2/2
✓ Branch 0 taken 19934 times.
✓ Branch 1 taken 147 times.
20081 if(get_qr(qr_OLD_WIZZROBE_SUBMERGING))
11731 {
11732 19934 hxofs = set?1000:0;
11733 19934 return;
11734 }
11735
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 147 times.
147 if(submerged == set) return;
11736 147 submerged = set;
11737
2/2
✓ Branch 0 taken 76 times.
✓ Branch 1 taken 71 times.
147 if(set)
11738 76 hxofs+=1000;
11739 71 else hxofs -= 1000;
11740 20081 }
11741 5326 eWizzrobe::eWizzrobe(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
11742 5326 {
11743 5326 hxofs = 0;
11744 5326 submerged = false;
11745
2/2
✓ Branch 0 taken 2358 times.
✓ Branch 1 taken 2968 times.
5326 switch(dmisc1)
11746 {
11747 case 0:
11748 2968 submerge(true);
11749 2968 fading=fade_invisible;
11750 // Set clk to just before the 'reappear' threshold
11751
9/10
✓ Branch 0 taken 2967 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 2967 times.
✓ Branch 3 taken 1 times.
✓ Branch 4 taken 1184 times.
✓ Branch 5 taken 1784 times.
✓ Branch 6 taken 1184 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1783 times.
✓ Branch 9 taken 1 times.
2968 clk=zc_min(clk+(146+zc_max(0,dmisc5))+14,(146+zc_max(0,dmisc5))-1);
11752 2968 break;
11753
11754 default:
11755 2358 dir=(loadside==right)?right:left;
11756 2358 misc=-3;
11757 2358 break;
11758 }
11759
11760 //netst+2880;
11761 5326 charging=false;
11762 5326 firing=false;
11763 5326 fclk=0;
11764
2/2
✓ Branch 0 taken 2358 times.
✓ Branch 1 taken 2968 times.
5326 if(!dmisc1) frate=1200+146; //1200 = 20 seconds
11765
1/4
✓ Branch 0 taken 5326 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
5326 if (SIZEflags != 0) init_size_flags();;
11766 5326 }
11767
11768 2075375 bool eWizzrobe::animate(int32_t index)
11769 {
11770
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2075375 times.
2075375 if(switch_hooked) return enemy::animate(index);
11771
2/4
✓ Branch 0 taken 2075375 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2075375 times.
2075375 if(fallclk||drownclk) return enemy::animate(index);
11772
2/2
✓ Branch 0 taken 37967 times.
✓ Branch 1 taken 2037408 times.
2075375 if(dying)
11773 {
11774 37967 return Dead(index);
11775 }
11776
11777
2/2
✓ Branch 0 taken 1970803 times.
✓ Branch 1 taken 66605 times.
2037408 if(clk==0)
11778 {
11779 66605 removearmos(x,y,ffcactivated);
11780 66605 }
11781
11782
2/2
✓ Branch 0 taken 1019220 times.
✓ Branch 1 taken 1018188 times.
2037408 if(dmisc1) // Floating
11783 {
11784 1019220 wizzrobe_attack();
11785 1019220 }
11786 else // Teleporting
11787 {
11788
5/6
✓ Branch 0 taken 1011104 times.
✓ Branch 1 taken 7084 times.
✓ Branch 2 taken 11087 times.
✓ Branch 3 taken 1000017 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 11087 times.
1018188 if(watch || (!get_qr(qr_WIZZROBES_DONT_OBEY_STUN) && stunclk))
11789 {
11790 7084 fading=0;
11791 7084 submerge(false);
11792 7084 solid_update(false);
11793 7084 }
11794
8/8
✓ Branch 0 taken 977386 times.
✓ Branch 1 taken 6199 times.
✓ Branch 2 taken 5284 times.
✓ Branch 3 taken 5122 times.
✓ Branch 4 taken 4977 times.
✓ Branch 5 taken 4222 times.
✓ Branch 6 taken 4084 times.
✓ Branch 7 taken 3830 times.
1011104 else switch(clk)
11795 {
11796 case 0:
11797
2/2
✓ Branch 0 taken 1117 times.
✓ Branch 1 taken 5082 times.
6199 if(!dmisc2)
11798 {
11799 // Wizzrobe Misc4 controls whether wizzrobes can teleport on top of solid combos,
11800 // but should not appear on dungeon walls.
11801
2/2
✓ Branch 0 taken 413 times.
✓ Branch 1 taken 4669 times.
5082 if ( FFCore.getQuestHeaderInfo(vZelda) <= 0x190 ) place_on_axis(true, false); //1.84, and probably 1.90 wizzrobes should NEVER appear in dungeon walls.-Z (1.84 confirmed, 15th January, 2019 by Chris Miller).
11802
2/2
✓ Branch 0 taken 224 times.
✓ Branch 1 taken 4445 times.
4669 else if (editorflags&ENEMY_FLAG5)
11803 {
11804 //2.10 Windrobe
11805 //randomise location and face Hero
11806 224 int32_t t=0;
11807 224 bool placed=false;
11808
11809
4/4
✓ Branch 0 taken 224 times.
✓ Branch 1 taken 367 times.
✓ Branch 2 taken 367 times.
✓ Branch 3 taken 224 times.
591 while(!placed && t<160)
11810 {
11811
2/2
✓ Branch 0 taken 280 times.
✓ Branch 1 taken 87 times.
367 if(isdungeon())
11812 {
11813 280 x=((zc_oldrand()%12)+2)*16;
11814 280 y=((zc_oldrand()%7)+2)*16;
11815 280 }
11816 else
11817 {
11818 87 x=((zc_oldrand()%14)+1)*16;
11819 87 y=((zc_oldrand()%9)+1)*16;
11820 }
11821
11822
6/6
✓ Branch 0 taken 123 times.
✓ Branch 1 taken 244 times.
✓ Branch 2 taken 187 times.
✓ Branch 3 taken 57 times.
✓ Branch 4 taken 143 times.
✓ Branch 5 taken 224 times.
611 if(!m_walkflag(x,y,spw_door, dir)&&((abs(x-Hero.getX())>=32)||(abs(y-Hero.getY())>=32)))
11823 {
11824 224 placed=true;
11825 224 }
11826
11827 367 ++t;
11828 }
11829
11830
2/2
✓ Branch 0 taken 61 times.
✓ Branch 1 taken 163 times.
224 if(abs(x-Hero.getX())<abs(y-Hero.getY()))
11831 {
11832
2/2
✓ Branch 0 taken 47 times.
✓ Branch 1 taken 14 times.
61 if(y<Hero.getY())
11833 {
11834 47 dir=down;
11835 47 }
11836 else
11837 {
11838 14 dir=up;
11839 }
11840 61 }
11841 else
11842 {
11843
2/2
✓ Branch 0 taken 91 times.
✓ Branch 1 taken 72 times.
163 if(x<Hero.getX())
11844 {
11845 72 dir=right;
11846 72 }
11847 else
11848 {
11849 91 dir=left;
11850 }
11851 }
11852
11853
1/2
✓ Branch 0 taken 224 times.
✗ Branch 1 not taken.
224 if(!placed) // can't place him, he's gone
11854 return true;
11855
11856
11857 //wizzrobe_attack(); //Complaint about 2.10 Windrobes not behaving as they did in 2.10. Let's try it this way. -Z
11858 //wizzrobe_attack_for_real(); //doing this makes them fire twice. The rest is correct.
11859 224 }
11860 4445 else place_on_axis(true, dmisc4!=0);
11861 5082 }
11862 else
11863 {
11864 1117 int32_t t=0;
11865 1117 bool placed=false;
11866
11867
4/4
✓ Branch 0 taken 1117 times.
✓ Branch 1 taken 2443 times.
✓ Branch 2 taken 2443 times.
✓ Branch 3 taken 1117 times.
3560 while(!placed && t<160)
11868 {
11869
2/2
✓ Branch 0 taken 1340 times.
✓ Branch 1 taken 1103 times.
2443 if(isdungeon())
11870 {
11871 1340 x=((zc_oldrand()%12)+2)*16;
11872 1340 y=((zc_oldrand()%7)+2)*16;
11873 1340 }
11874 else
11875 {
11876 1103 x=((zc_oldrand()%14)+1)*16;
11877 1103 y=((zc_oldrand()%9)+1)*16;
11878 }
11879
11880
6/6
✓ Branch 0 taken 1130 times.
✓ Branch 1 taken 1313 times.
✓ Branch 2 taken 898 times.
✓ Branch 3 taken 415 times.
✓ Branch 4 taken 1326 times.
✓ Branch 5 taken 1117 times.
3756 if(!m_walkflag(x,y,spw_door, dir)&&((abs(x-Hero.getX())>=32)||(abs(y-Hero.getY())>=32)))
11881 {
11882 1117 placed=true;
11883 1117 }
11884
11885 2443 ++t;
11886 }
11887
11888
2/2
✓ Branch 0 taken 386 times.
✓ Branch 1 taken 731 times.
1117 if(abs(x-Hero.getX())<abs(y-Hero.getY()))
11889 {
11890
2/2
✓ Branch 0 taken 238 times.
✓ Branch 1 taken 148 times.
386 if(y<Hero.getY())
11891 {
11892 238 dir=down;
11893 238 }
11894 else
11895 {
11896 148 dir=up;
11897 }
11898 386 }
11899 else
11900 {
11901
2/2
✓ Branch 0 taken 340 times.
✓ Branch 1 taken 391 times.
731 if(x<Hero.getX())
11902 {
11903 340 dir=right;
11904 340 }
11905 else
11906 {
11907 391 dir=left;
11908 }
11909 }
11910
11911
1/2
✓ Branch 0 taken 1117 times.
✗ Branch 1 not taken.
1117 if(!placed) // can't place him, he's gone
11912 return true;
11913 }
11914
11915 6199 fading=fade_flicker;
11916 6199 submerge(false);
11917 6199 solid_update(false);
11918 6199 break;
11919
11920 case 64:
11921 5284 fading=0;
11922 5284 charging=true;
11923 5284 break;
11924
11925 case 73:
11926 5122 charging=false;
11927 5122 firing=40;
11928 5122 break;
11929
11930 case 83:
11931 4977 wizzrobe_attack_for_real();
11932 4977 break;
11933
11934 case 119:
11935 4222 firing=false;
11936 4222 charging=true;
11937 4222 break;
11938
11939 case 128:
11940 4084 fading=fade_flicker;
11941 4084 charging=false;
11942 4084 break;
11943
11944 case 146:
11945 3830 fading=fade_invisible;
11946 3830 submerge(true);
11947 3830 solid_update(false);
11948
11949 [[fallthrough]];
11950 default:
11951
4/4
✓ Branch 0 taken 981056 times.
✓ Branch 1 taken 160 times.
✓ Branch 2 taken 975008 times.
✓ Branch 3 taken 6208 times.
981216 if(clk>=(146+zc_max(0,dmisc5)))
11952 6208 clk=-1;
11953
11954 981216 break;
11955 }
11956 }
11957
11958 2037408 return enemy::animate(index);
11959 2075375 }
11960
11961 7900 void eWizzrobe::wizzrobe_attack_for_real()
11962 {
11963
1/2
✓ Branch 0 taken 7900 times.
✗ Branch 1 not taken.
7900 if(wpn==0) // Edited enemies
11964 return;
11965
11966
2/2
✓ Branch 0 taken 1983 times.
✓ Branch 1 taken 5917 times.
7900 if(dmisc2 == 0) //normal weapon
11967 {
11968 5917 addEwpn(x,y,z,wpn,0,wdp,dir,getUID(), 0, fakez);
11969 5917 sfx(firesfx, pan(int32_t(x)));
11970 5917 }
11971
2/2
✓ Branch 0 taken 995 times.
✓ Branch 1 taken 988 times.
1983 else if(dmisc2 == 1) // ring of fire
11972 {
11973 995 addEwpn(x,y,z,wpn,0,wdp,up,getUID(), 0, fakez);
11974 995 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
11975 995 addEwpn(x,y,z,wpn,0,wdp,down,getUID(), 0, fakez);
11976 995 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
11977 995 addEwpn(x,y,z,wpn,0,wdp,left,getUID(), 0, fakez);
11978 995 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
11979 995 addEwpn(x,y,z,wpn,0,wdp,right,getUID(), 0, fakez);
11980 995 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
11981 995 addEwpn(x,y,z,wpn,0,wdp,l_up,getUID(), 0, fakez);
11982 995 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
11983 995 addEwpn(x,y,z,wpn,0,wdp,r_up,getUID(), 0, fakez);
11984 995 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
11985 995 addEwpn(x,y,z,wpn,0,wdp,l_down,getUID(), 0, fakez);
11986 995 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
11987 995 addEwpn(x,y,z,wpn,0,wdp,r_down,getUID(), 0, fakez);
11988 995 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
11989 //this block of code was buggy and flat out doesn't match the default wpnsfx for these weapons.
11990 //i've compromised by making all old quest use this code chunk by default.
11991
1/2
✓ Branch 0 taken 995 times.
✗ Branch 1 not taken.
995 if (FFCore.quest_format[vGuys] < 51)
11992 {
11993 995 sfx(WAV_FIRE, pan(int32_t(x)));
11994
2/2
✓ Branch 0 taken 488 times.
✓ Branch 1 taken 507 times.
995 if (get_qr(qr_8WAY_SHOT_SFX_DEP)) sfx(WAV_FIRE,pan(int32_t(x)));
11995 else
11996 {
11997
3/17
✗ Branch 0 not taken.
✓ Branch 1 taken 19 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 68 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 420 times.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
507 switch (wpn)
11998 {
11999 19 case ewFireball: sfx(40, pan(int32_t(x))); break;
12000 case ewBrang: sfx(4, pan(int32_t(x))); break; //Ghost.zh has 0?
12001 case ewSword: sfx(20, pan(int32_t(x))); break; //Ghost.zh has 0?
12002 case ewRock: sfx(51, pan(int32_t(x))); break;
12003 68 case ewMagic: sfx(32, pan(int32_t(x))); break;
12004 case ewBomb: sfx(3, pan(int32_t(x))); break; //Ghost.zh has 0?
12005 case ewSBomb: sfx(3, pan(int32_t(x))); break; //Ghost.zh has 0?
12006 case ewLitBomb: sfx(21, pan(int32_t(x))); break; //Ghost.zh has 0?
12007 case ewLitSBomb: sfx(21, pan(int32_t(x))); break; //Ghost.zh has 0?
12008 case ewFireTrail: sfx(13, pan(int32_t(x))); break;
12009 420 case ewFlame: sfx(13, pan(int32_t(x))); break;
12010 case ewWind: sfx(32, pan(int32_t(x))); break;
12011 case ewFlame2: sfx(13, pan(int32_t(x))); break;
12012 case ewFlame2Trail: sfx(13, pan(int32_t(x))); break;
12013 case ewIce: sfx(44, pan(int32_t(x))); break;
12014 case ewFireball2: sfx(40, pan(int32_t(x))); break; //fireball (rising)
12015 default: sfx(WAV_FIRE, pan(int32_t(x))); break;
12016 }
12017 }
12018 995 }
12019 else
12020 {
12021 sfx(firesfx, pan(int32_t(x)));
12022 }
12023 995 }
12024
2/2
✓ Branch 0 taken 971 times.
✓ Branch 1 taken 17 times.
988 else if(dmisc2==2) // summons specific enemy
12025 {
12026 971 int32_t bc=0;
12027
12028
2/2
✓ Branch 0 taken 10497 times.
✓ Branch 1 taken 971 times.
11468 for(int32_t gc=0; gc<guys.Count(); gc++)
12029 {
12030
2/2
✓ Branch 0 taken 5302 times.
✓ Branch 1 taken 5195 times.
10497 if((((enemy*)guys.spr(gc))->id) == dmisc3)
12031 {
12032 5195 ++bc;
12033 5195 }
12034 10497 }
12035
12036
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 963 times.
971 if(bc<=40)
12037 {
12038 963 int32_t kids = guys.Count();
12039 963 int32_t bats=(zc_oldrand()%3)+1;
12040
12041
2/2
✓ Branch 0 taken 1965 times.
✓ Branch 1 taken 963 times.
2928 for(int32_t i=0; i<bats; i++)
12042 {
12043 // Summon bats (or anything)
12044
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1965 times.
1965 if(addchild(x,y,dmisc3,-10, this->script_UID))
12045 1965 ((enemy*)guys.spr(kids+i))->count_enemy = false;
12046 1965 }
12047 963 sfx(firesfx, pan(int32_t(x)));
12048 963 }
12049 971 }
12050
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
17 else if(dmisc2==3) //summon from layer
12051 {
12052
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(count_layer_enemies()==0)
12053 {
12054 return;
12055 }
12056
12057 17 int32_t kids = guys.Count();
12058
12059
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
17 if(kids<200)
12060 {
12061 17 int32_t newguys=(zc_oldrand()%3)+1;
12062 17 bool summoned=false;
12063
12064
2/2
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 17 times.
49 for(int32_t i=0; i<newguys; i++)
12065 {
12066 32 int32_t id2=vbound(random_layer_enemy(),eSTART,eMAXGUYS-1);
12067 32 int32_t x2=0;
12068 32 int32_t y2=0;
12069
12070
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 36 times.
36 for(int32_t k=0; k<20; ++k)
12071 {
12072 36 x2=16*((zc_oldrand()%12)+2);
12073 36 y2=16*((zc_oldrand()%7)+2);
12074
12075
5/6
✗ Branch 0 not taken.
✓ Branch 1 taken 36 times.
✓ Branch 2 taken 21 times.
✓ Branch 3 taken 15 times.
✓ Branch 4 taken 4 times.
✓ Branch 5 taken 32 times.
72 if(!m_walkflag(x2,y2,0, dir) && (abs(x2-Hero.getX())>=32 || abs(y2-Hero.getY())>=32))
12076 {
12077
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 32 times.
32 if(addchild(x2,y2,get_qr(qr_ENEMIESZAXIS) ? 64 : 0,id2,-10, this->script_UID))
12078 {
12079 32 ((enemy*)guys.spr(kids+i))->count_enemy = false;
12080
3/4
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 25 times.
✓ Branch 2 taken 7 times.
✗ Branch 3 not taken.
32 if (get_qr(qr_ENEMIESZAXIS) && (((enemy*)guys.spr(kids+i))->moveflags & move_use_fake_z))
12081 {
12082 ((enemy*)guys.spr(kids+i))->fakez = 64;
12083 ((enemy*)guys.spr(kids+i))->z = 0;
12084 }
12085 32 }
12086
12087 32 summoned=true;
12088 32 break;
12089 }
12090 4 }
12091 32 }
12092
12093
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
17 if(summoned)
12094 {
12095 17 sfx(firesfx, pan(int32_t(x)));
12096 17 }
12097 17 }
12098 17 }
12099 7900 }
12100
12101
12102 1019220 void eWizzrobe::wizzrobe_attack()
12103 {
12104
10/12
✓ Branch 0 taken 982487 times.
✓ Branch 1 taken 36733 times.
✓ Branch 2 taken 982487 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 937882 times.
✓ Branch 5 taken 44605 times.
✓ Branch 6 taken 934499 times.
✓ Branch 7 taken 3383 times.
✓ Branch 8 taken 932879 times.
✓ Branch 9 taken 1620 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 932879 times.
1019220 if(clk<0 || dying || stunclk || watch || ceiling || frozenclock)
12105 86341 return;
12106
12107
3/8
✓ Branch 0 taken 893341 times.
✓ Branch 1 taken 39538 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 893341 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
932879 if(clk3<=0 || ((clk3&31)==0 && !canmove(dir,(zfix)1,spw_door,false) && !misc))
12108 {
12109 39538 fix_coords();
12110
12111
5/5
✓ Branch 0 taken 5496 times.
✓ Branch 1 taken 1050 times.
✓ Branch 2 taken 16081 times.
✓ Branch 3 taken 13008 times.
✓ Branch 4 taken 3903 times.
39538 switch(misc)
12112 {
12113 case 1: //walking
12114
2/2
✓ Branch 0 taken 10364 times.
✓ Branch 1 taken 2644 times.
13008 if(!m_walkflag(x,y,spw_door, dir))
12115 2644 misc=0;
12116 else
12117 {
12118 10364 clk3=16;
12119
12120
2/2
✓ Branch 0 taken 8966 times.
✓ Branch 1 taken 1398 times.
10364 if(!canmove(dir,(zfix)1,spw_wizzrobe,false))
12121 {
12122 1398 wizzrobe_newdir(0);
12123 1398 }
12124 }
12125
12126 13008 break;
12127
12128 case 2: //phasing
12129 {
12130 3903 int32_t jx=x;
12131 3903 int32_t jy=y;
12132 3903 int32_t jdir=-1;
12133
12134
5/5
✓ Branch 0 taken 1973 times.
✓ Branch 1 taken 484 times.
✓ Branch 2 taken 472 times.
✓ Branch 3 taken 482 times.
✓ Branch 4 taken 492 times.
3903 switch(zc_oldrand()&7)
12135 {
12136 case 0:
12137 484 jx-=32;
12138 484 jy-=32;
12139 484 jdir=15;
12140 484 break;
12141
12142 case 1:
12143 472 jx+=32;
12144 472 jy-=32;
12145 472 jdir=9;
12146 472 break;
12147
12148 case 2:
12149 482 jx+=32;
12150 482 jy+=32;
12151 482 jdir=11;
12152 482 break;
12153
12154 case 3:
12155 492 jx-=32;
12156 492 jy+=32;
12157 492 jdir=13;
12158 492 break;
12159 }
12160
12161
10/10
✓ Branch 0 taken 1930 times.
✓ Branch 1 taken 1973 times.
✓ Branch 2 taken 1724 times.
✓ Branch 3 taken 206 times.
✓ Branch 4 taken 1597 times.
✓ Branch 5 taken 127 times.
✓ Branch 6 taken 1385 times.
✓ Branch 7 taken 212 times.
✓ Branch 8 taken 1140 times.
✓ Branch 9 taken 245 times.
3903 if(jdir>0 && jx>=32 && jx<=208 && jy>=32 && jy<=128)
12162 {
12163 1140 misc=3;
12164 1140 clk3=32;
12165 1140 dir=jdir;
12166 1140 break;
12167 }
12168 2763 }
12169 [[fallthrough]];
12170 case 3:
12171 3813 dir&=3;
12172 3813 misc=0;
12173 [[fallthrough]];
12174 case 0:
12175 19894 wizzrobe_newdir(64);
12176 [[fallthrough]];
12177 default:
12178
2/2
✓ Branch 0 taken 21886 times.
✓ Branch 1 taken 3504 times.
25390 if(!canmove(dir,(zfix)1,spw_door,false))
12179 {
12180
2/2
✓ Branch 0 taken 3265 times.
✓ Branch 1 taken 239 times.
3504 if(canmove(dir,(zfix)15,spw_wizzrobe,false))
12181 {
12182 3265 misc=1;
12183 3265 clk3=16;
12184 3265 }
12185 else
12186 {
12187 239 wizzrobe_newdir(64);
12188 239 misc=0;
12189 239 clk3=32;
12190 }
12191 3504 }
12192 else
12193 {
12194 21886 clk3=32;
12195 }
12196
12197 25390 break;
12198 }
12199
12200
2/2
✓ Branch 0 taken 35060 times.
✓ Branch 1 taken 4478 times.
39538 if(misc<0)
12201 4478 ++misc;
12202 39538 }
12203
12204 932879 --clk3;
12205
12206
3/3
✓ Branch 0 taken 248377 times.
✓ Branch 1 taken 620599 times.
✓ Branch 2 taken 63903 times.
932879 switch(misc)
12207 {
12208 case 1:
12209 case 3:
12210 248377 step=1;
12211 248377 break;
12212
12213 case 2:
12214 63903 step=0;
12215 63903 break;
12216
12217 default:
12218 620599 step=0.5;
12219 620599 break;
12220
12221 }
12222
12223 932879 move(step);
12224
12225 // if(d->misc1 && misc<=0 && clk3==28)
12226
5/6
✓ Branch 0 taken 932879 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 620599 times.
✓ Branch 3 taken 312280 times.
✓ Branch 4 taken 599052 times.
✓ Branch 5 taken 21547 times.
932879 if(dmisc1 && misc<=0 && clk3==28)
12227 {
12228
2/2
✓ Branch 0 taken 16835 times.
✓ Branch 1 taken 4712 times.
21547 if(dmisc2 != 1)
12229 {
12230
2/2
✓ Branch 0 taken 14907 times.
✓ Branch 1 taken 1928 times.
16835 if(lined_up(8,false) == dir)
12231 {
12232 // addEwpn(x,y,z,wpn,0,wdp,dir,getUID());
12233 // sfx(WAV_WAND,pan(int32_t(x)));
12234 1928 wizzrobe_attack_for_real();
12235 1928 fclk=30;
12236 1928 }
12237 16835 }
12238 else
12239 {
12240
2/2
✓ Branch 0 taken 3717 times.
✓ Branch 1 taken 995 times.
4712 if((zc_oldrand()%500)>=400)
12241 {
12242 995 wizzrobe_attack_for_real();
12243 995 fclk=30;
12244 995 }
12245 }
12246 21547 }
12247
12248
4/4
✓ Branch 0 taken 517526 times.
✓ Branch 1 taken 415353 times.
✓ Branch 2 taken 4050 times.
✓ Branch 3 taken 513476 times.
932879 if(misc==0 && (zc_oldrand()&127)==0)
12249 4050 misc=2;
12250
12251
4/4
✓ Branch 0 taken 67953 times.
✓ Branch 1 taken 864926 times.
✓ Branch 2 taken 64512 times.
✓ Branch 3 taken 3441 times.
932879 if(misc==2 && clk3==4)
12252 3441 fix_coords();
12253
12254
2/4
✓ Branch 0 taken 932879 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 932879 times.
932879 if(!(charging||firing)) //should never be charging or firing for these wizzrobes
12255 {
12256
2/2
✓ Branch 0 taken 849597 times.
✓ Branch 1 taken 83282 times.
932879 if(fclk>0)
12257 {
12258 83282 --fclk;
12259 83282 }
12260 932879 }
12261
12262 1019220 }
12263
12264 21531 void eWizzrobe::wizzrobe_newdir(int32_t homing)
12265 {
12266 // Wizzrobes shouldn't move to the edge of the screen;
12267 // if they're already there, they should move toward the center
12268
2/2
✓ Branch 0 taken 33 times.
✓ Branch 1 taken 21498 times.
21531 if(x<32)
12269 33 dir=right;
12270
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 21494 times.
21498 else if(x>=224)
12271 4 dir=left;
12272
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 21492 times.
21494 else if(y<32)
12273 2 dir=down;
12274
2/2
✓ Branch 0 taken 21487 times.
✓ Branch 1 taken 5 times.
21492 else if(y>=144)
12275 5 dir=up;
12276 else
12277 21487 newdir(4,homing,spw_wizzrobe);
12278 21531 }
12279
12280 2092991 void eWizzrobe::draw(BITMAP *dest)
12281 {
12282 // if(d->misc1 && (misc==1 || misc==3) && (clk3&1) && hp>0 && !watch && !stunclk) // phasing
12283
13/14
✓ Branch 0 taken 1042483 times.
✓ Branch 1 taken 1050508 times.
✓ Branch 2 taken 817873 times.
✓ Branch 3 taken 224610 times.
✓ Branch 4 taken 132112 times.
✓ Branch 5 taken 910371 times.
✓ Branch 6 taken 130752 times.
✓ Branch 7 taken 1360 times.
✓ Branch 8 taken 129926 times.
✓ Branch 9 taken 826 times.
✓ Branch 10 taken 125018 times.
✓ Branch 11 taken 4908 times.
✓ Branch 12 taken 125018 times.
✗ Branch 13 not taken.
2092991 if(dmisc1 && (misc==1 || misc==3) && (clk3&1) && hp>0 && !watch && !stunclk && !frozenclock) // phasing
12284 125018 return;
12285
12286 1967973 int32_t tempint=dummy_int[1];
12287 1967973 bool tempbool1=dummy_bool[1];
12288 1967973 bool tempbool2=dummy_bool[2];
12289 1967973 dummy_int[1]=fclk;
12290 1967973 dummy_bool[1]=charging;
12291 1967973 dummy_bool[2]=firing;
12292 1967973 update_enemy_frame();
12293 1967973 dummy_int[1]=tempint;
12294 1967973 dummy_bool[1]=tempbool1;
12295 1967973 dummy_bool[2]=tempbool2;
12296 1967973 enemy::draw(dest);
12297 2092991 }
12298
12299 203 eDodongo::eDodongo(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
12300 203 {
12301 203 fading=fade_flash_die;
12302
6/8
✓ Branch 0 taken 49 times.
✓ Branch 1 taken 154 times.
✓ Branch 2 taken 49 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 49 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 3 times.
✓ Branch 7 taken 46 times.
203 if(dir==down&&y>=128)
12303 {
12304 3 dir=up;
12305 3 }
12306
12307
5/8
✓ Branch 0 taken 62 times.
✓ Branch 1 taken 141 times.
✓ Branch 2 taken 62 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 62 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 62 times.
203 if(dir==right&&x>=208)
12308 {
12309 dir=left;
12310 }
12311
1/4
✓ Branch 0 taken 203 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
203 if (SIZEflags != 0) init_size_flags();;
12312 203 }
12313
12314 125855 bool eDodongo::animate(int32_t index)
12315 {
12316
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 125855 times.
125855 if(switch_hooked) return enemy::animate(index);
12317
2/2
✓ Branch 0 taken 3790 times.
✓ Branch 1 taken 122065 times.
125855 if(dying)
12318 {
12319 3790 return Dead(index);
12320 }
12321
12322
2/2
✓ Branch 0 taken 121496 times.
✓ Branch 1 taken 569 times.
122065 if(clk==0)
12323 {
12324 569 removearmos(x,y,ffcactivated);
12325 569 }
12326
12327
2/2
✓ Branch 0 taken 10848 times.
✓ Branch 1 taken 111217 times.
122065 if(clk2) // ate a bomb
12328 {
12329
2/2
✓ Branch 0 taken 10735 times.
✓ Branch 1 taken 113 times.
10848 if(--clk2==0)
12330 113 hp-=misc; // store bomb's power in misc
12331 10848 }
12332 else
12333 111217 constant_walk(rate,homing,spw_clipright);
12334
12335 122065 hit_width = (dir<=down) ? 16 : 32;
12336 // hysz = (dir>=left) ? 16 : 32;
12337
12338 122065 return enemy::animate(index);
12339 125855 }
12340
12341 125845 void eDodongo::draw(BITMAP *dest)
12342 {
12343 125845 tile=o_tile;
12344
12345
2/2
✓ Branch 0 taken 3065 times.
✓ Branch 1 taken 122780 times.
125845 if(clk<0)
12346 {
12347 3065 enemy::drawzcboss(dest);
12348 3065 return;
12349 }
12350
12351 122780 update_enemy_frame();
12352 122780 enemy::drawzcboss(dest);
12353
12354
2/2
✓ Branch 0 taken 51662 times.
✓ Branch 1 taken 71118 times.
122780 if(dummy_int[1]!=0) //additional tiles
12355 {
12356 71118 tile+=dummy_int[1]; //second tile is previous tile
12357 71118 xofs-=16; //new xofs change
12358 71118 enemy::drawzcboss(dest);
12359 71118 xofs+=16;
12360 71118 }
12361
12362 125845 }
12363
12364 8218 int32_t eDodongo::takehit(weapon *w, weapon* realweap)
12365 {
12366 8218 int32_t wpnId = w->id;
12367 8218 int32_t power = w->power;
12368 8218 int32_t wpnx = w->x;
12369 8218 int32_t wpny = w->y;
12370
12371
5/12
✓ Branch 0 taken 8218 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8218 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2457 times.
✓ Branch 5 taken 5761 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 2457 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
8218 if(dying || clk<0 || clk2>0 || (superman && !(superman>1 && wpnId==wSBomb)))
12372 5761 return 0;
12373
12374
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 803 times.
✓ Branch 2 taken 1491 times.
✓ Branch 3 taken 17 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 146 times.
2457 switch(wpnId)
12375 {
12376 case wPhantom:
12377 return 0;
12378
12379 case wFire:
12380 case wBait:
12381 case wWhistle:
12382 case wWind:
12383 case wSSparkle:
12384 case wFSparkle:
12385 return 0;
12386
12387 case wLitBomb:
12388 case wLitSBomb:
12389
6/6
✓ Branch 0 taken 266 times.
✓ Branch 1 taken 537 times.
✓ Branch 2 taken 293 times.
✓ Branch 3 taken 510 times.
✓ Branch 4 taken 690 times.
✓ Branch 5 taken 113 times.
803 if(abs(wpnx-((dir==right)?x+16:x)) > 7 || abs(wpny-y) > 7)
12390 690 return 0;
12391
12392 113 clk2=96;
12393 113 misc=power;
12394
12395
2/2
✓ Branch 0 taken 110 times.
✓ Branch 1 taken 3 times.
113 if(wpnId==wLitSBomb)
12396 3 item_set=isSBOMB100;
12397
12398 113 return 1;
12399
12400 case wBomb:
12401 case wSBomb:
12402
6/6
✓ Branch 0 taken 427 times.
✓ Branch 1 taken 1064 times.
✓ Branch 2 taken 420 times.
✓ Branch 3 taken 1071 times.
✓ Branch 4 taken 516 times.
✓ Branch 5 taken 975 times.
1491 if(abs(wpnx-((dir==right)?x+16:x)) > 8 || abs(wpny-y) > 8)
12403 516 return 0;
12404
12405 975 stunclk=160;
12406 975 misc=wpnId; // store wpnId
12407 975 return 1;
12408
12409 case wSword:
12410
2/2
✓ Branch 0 taken 58 times.
✓ Branch 1 taken 88 times.
146 if(stunclk)
12411 {
12412 88 sfx(WAV_EHIT,pan(int32_t(x)));
12413 88 hp=0;
12414 88 item_set = (misc==wSBomb) ? isSBOMB100 : isBOMB100;
12415 88 fading=0; // don't flash
12416 88 return 1;
12417 }
12418
12419 [[fallthrough]];
12420 default:
12421 75 sfx(WAV_CHINK,pan(int32_t(x)));
12422 75 }
12423
12424 75 return 1;
12425 8218 }
12426
12427 48 eDodongo2::eDodongo2(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
12428 48 {
12429 48 fading=fade_flash_die;
12430 //nets+5180;
12431 48 previous_dir=-1;
12432
6/8
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 34 times.
✓ Branch 2 taken 14 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 14 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1 times.
✓ Branch 7 taken 13 times.
48 if(dir==down&&y>=128)
12433 {
12434 1 dir=up;
12435 1 }
12436
12437
5/8
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 36 times.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 12 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 12 times.
48 if(dir==right&&x>=208)
12438 {
12439 dir=left;
12440 }
12441
1/4
✓ Branch 0 taken 48 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
48 if (SIZEflags != 0) init_size_flags();;
12442 48 }
12443
12444 39398 bool eDodongo2::animate(int32_t index)
12445 {
12446
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 39398 times.
39398 if(switch_hooked) return enemy::animate(index);
12447
2/2
✓ Branch 0 taken 1158 times.
✓ Branch 1 taken 38240 times.
39398 if(dying)
12448 {
12449 1158 return Dead(index);
12450 }
12451
12452
2/2
✓ Branch 0 taken 38073 times.
✓ Branch 1 taken 167 times.
38240 if(clk==0)
12453 {
12454 167 removearmos(x,y,ffcactivated);
12455 167 }
12456
12457
2/2
✓ Branch 0 taken 4032 times.
✓ Branch 1 taken 34208 times.
38240 if(clk2) // ate a bomb
12458 {
12459
2/2
✓ Branch 0 taken 3990 times.
✓ Branch 1 taken 42 times.
4032 if(--clk2==0)
12460 42 hp-=misc; // store bomb's power in misc
12461 4032 }
12462 else
12463 34208 constant_walk(rate,homing,spw_clipbottomright);
12464
12465 38240 hit_width = (dir<=down) ? 16 : 32;
12466 38240 hit_height = (dir>=left) ? 16 : 32;
12467 38240 hxofs=(dir>=left)?-8:0;
12468 38240 hyofs=(dir<left)?-8:0;
12469
12470 38240 return enemy::animate(index);
12471 39398 }
12472
12473 39601 void eDodongo2::draw(BITMAP *dest)
12474 {
12475
2/2
✓ Branch 0 taken 768 times.
✓ Branch 1 taken 38833 times.
39601 if(clk<0)
12476 {
12477 768 enemy::drawzcboss(dest);
12478 768 return;
12479 }
12480
12481 38833 int32_t tempx=xofs;
12482 38833 int32_t tempy=yofs;
12483 38833 update_enemy_frame();
12484 38833 enemy::drawzcboss(dest);
12485 38833 tile+=dummy_int[1]; //second tile change
12486 38833 xofs+=dummy_int[2]; //new xofs change
12487 38833 yofs+=dummy_int[3]; //new yofs change
12488 38833 enemy::drawzcboss(dest);
12489 38833 xofs=tempx;
12490 38833 yofs=tempy;
12491 39601 }
12492
12493 3929 int32_t eDodongo2::takehit(weapon *w, weapon* realweap)
12494 {
12495 3929 int32_t wpnId = w->id;
12496 3929 int32_t power = w->power;
12497 3929 int32_t wpnx = w->x;
12498 3929 int32_t wpny = w->y;
12499
12500
5/8
✓ Branch 0 taken 3929 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3929 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1552 times.
✓ Branch 5 taken 2377 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 1552 times.
3929 if(dying || clk<0 || clk2>0 || superman)
12501 2377 return 0;
12502
12503
5/6
✓ Branch 0 taken 346 times.
✓ Branch 1 taken 321 times.
✓ Branch 2 taken 693 times.
✓ Branch 3 taken 31 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 161 times.
1552 switch(wpnId)
12504 {
12505 case wPhantom:
12506 return 0;
12507
12508 case wFire:
12509 case wBait:
12510 case wWhistle:
12511 case wWind:
12512 case wSSparkle:
12513 case wFSparkle:
12514 346 return 0;
12515
12516 case wLitBomb:
12517 case wLitSBomb:
12518
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 81 times.
✓ Branch 2 taken 77 times.
✓ Branch 3 taken 82 times.
✓ Branch 4 taken 81 times.
321 switch(dir)
12519 {
12520 case up:
12521
4/4
✓ Branch 0 taken 33 times.
✓ Branch 1 taken 48 times.
✓ Branch 2 taken 77 times.
✓ Branch 3 taken 4 times.
81 if(abs(wpnx-x) > 7 || abs(wpny-(y-8)) > 7)
12522 77 return 0;
12523
12524 4 break;
12525
12526 case down:
12527
4/4
✓ Branch 0 taken 39 times.
✓ Branch 1 taken 38 times.
✓ Branch 2 taken 71 times.
✓ Branch 3 taken 6 times.
77 if(abs(wpnx-x) > 7 || abs(wpny-(y+8)) > 7)
12528 71 return 0;
12529
12530 6 break;
12531
12532 case left:
12533
4/4
✓ Branch 0 taken 42 times.
✓ Branch 1 taken 40 times.
✓ Branch 2 taken 66 times.
✓ Branch 3 taken 16 times.
82 if(abs(wpnx-(x-8)) > 7 || abs(wpny-y) > 7)
12534 66 return 0;
12535
12536 16 break;
12537
12538 case right:
12539
4/4
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 65 times.
✓ Branch 2 taken 65 times.
✓ Branch 3 taken 16 times.
81 if(abs(wpnx-(x+8)) > 7 || abs(wpny-y) > 7)
12540 65 return 0;
12541
12542 16 break;
12543 }
12544
12545 // if(abs(wpnx-((dir==right)?x+8:(dir==left)?x-8:0)) > 7 || abs(wpny-((dir==down)?y+8:(dir==up)?y-8:0)) > 7)
12546 // return 0;
12547 42 clk2=96;
12548 42 misc=power;
12549
12550
1/2
✓ Branch 0 taken 42 times.
✗ Branch 1 not taken.
42 if(wpnId==wLitSBomb)
12551 item_set=isSBOMB100;
12552
12553 42 return 1;
12554
12555 case wBomb:
12556 case wSBomb:
12557
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 176 times.
✓ Branch 2 taken 168 times.
✓ Branch 3 taken 185 times.
✓ Branch 4 taken 164 times.
693 switch(dir)
12558 {
12559 case up:
12560
4/4
✓ Branch 0 taken 121 times.
✓ Branch 1 taken 55 times.
✓ Branch 2 taken 84 times.
✓ Branch 3 taken 92 times.
176 if(abs(wpnx-x) > 7 || abs(wpny-(y-8)) > 7)
12561 84 return 0;
12562
12563 92 break;
12564
12565 case down:
12566
4/4
✓ Branch 0 taken 81 times.
✓ Branch 1 taken 87 times.
✓ Branch 2 taken 113 times.
✓ Branch 3 taken 55 times.
168 if(abs(wpnx-x) > 7 || abs(wpny-(y+8)) > 7)
12567 113 return 0;
12568
12569 55 break;
12570
12571 case left:
12572
4/4
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 80 times.
✓ Branch 2 taken 80 times.
✓ Branch 3 taken 105 times.
185 if(abs(wpnx-(x-8)) > 7 || abs(wpny-y) > 7)
12573 80 return 0;
12574
12575 105 break;
12576
12577 case right:
12578
4/4
✓ Branch 0 taken 97 times.
✓ Branch 1 taken 67 times.
✓ Branch 2 taken 71 times.
✓ Branch 3 taken 93 times.
164 if(abs(wpnx-(x+8)) > 7 || abs(wpny-y) > 7)
12579 71 return 0;
12580
12581 93 break;
12582 }
12583
12584 345 stunclk=160;
12585 345 misc=wpnId; // store wpnId
12586 345 return 1;
12587
12588 case wSword:
12589
2/2
✓ Branch 0 taken 127 times.
✓ Branch 1 taken 34 times.
161 if(stunclk)
12590 {
12591 34 sfx(WAV_EHIT,pan(int32_t(x)));
12592 34 hp=0;
12593 34 item_set = (misc==wSBomb) ? isSBOMB100 : isBOMB100;
12594 34 fading=0; // don't flash
12595 34 return 1;
12596 }
12597
12598 [[fallthrough]];
12599 default:
12600 158 sfx(WAV_CHINK,pan(int32_t(x)));
12601 158 }
12602
12603 158 return 1;
12604 3929 }
12605
12606 126 eAquamentus::eAquamentus(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)//enemy((zfix)176,(zfix)64,Id,Clk)
12607 126 {
12608 //these are here to bypass compiler warnings about unused arguments
12609
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 if ( !(editorflags & ENEMY_FLAG5) )
12610 {
12611
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 x = dmisc1 ? 64 : 176;
12612
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 y = 64;
12613 126 }
12614 else { x = X; y = Y; }
12615
12616 //nets+5940;
12617
2/2
✓ Branch 0 taken 81 times.
✓ Branch 1 taken 45 times.
126 if(get_qr(qr_NEWENEMYTILES))
12618 {
12619 81 }
12620 else
12621 {
12622
2/2
✓ Branch 0 taken 38 times.
✓ Branch 1 taken 7 times.
45 if(dmisc1)
12623 {
12624 7 flip=1;
12625 7 }
12626 }
12627
12628
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 126 times.
✓ Branch 2 taken 126 times.
✗ Branch 3 not taken.
126 yofs=(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset)+1;
12629 126 clk3=32;
12630 126 clk2=0;
12631 126 clk4=clk;
12632 126 dir=left;
12633
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 126 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
126 if (SIZEflags != 0) init_size_flags();;
12634 126 }
12635
12636 71899 bool eAquamentus::animate(int32_t index)
12637 {
12638
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 71899 times.
71899 if(switch_hooked) return enemy::animate(index);
12639
2/2
✓ Branch 0 taken 2092 times.
✓ Branch 1 taken 69807 times.
71899 if(dying)
12640 2092 return Dead(index);
12641
12642 // fbx=x+((id==eRAQUAM)?4:-4);
12643
2/2
✓ Branch 0 taken 69490 times.
✓ Branch 1 taken 317 times.
69807 if(clk==0)
12644 {
12645 317 removearmos(x,y,ffcactivated);
12646 317 }
12647
12648 69807 fbx=x;
12649
12650 /*
12651 if (get_qr(qr_NEWENEMYTILES)&&id==eLAQUAM)
12652 {
12653 fbx+=16;
12654 }
12655 */
12656
2/2
✓ Branch 0 taken 69357 times.
✓ Branch 1 taken 450 times.
69807 if(--clk3==0)
12657 {
12658 // addEwpn(fbx,y,z,ewFireball,0,d->wdp,up+1);
12659 // addEwpn(fbx,y,z,ewFireball,0,d->wdp,0);
12660 // addEwpn(fbx,y,z,ewFireball,0,d->wdp,down+1);
12661 450 addEwpn(fbx,y,z,wpn,2,wdp,up,getUID(), 0, fakez);
12662 450 addEwpn(fbx,y,z,wpn,2,wdp,8,getUID(), 0, fakez);
12663 450 addEwpn(fbx,y,z,wpn,2,wdp,down,getUID(), 0, fakez);
12664 450 sfx(wpnsfx(wpn),pan(int32_t(x)));
12665 450 }
12666
12667
4/4
✓ Branch 0 taken 21363 times.
✓ Branch 1 taken 48444 times.
✓ Branch 2 taken 345 times.
✓ Branch 3 taken 21018 times.
69807 if(clk3<-80 && !(zc_oldrand()&63))
12668 {
12669 345 clk3=32;
12670 345 }
12671
12672
2/2
✓ Branch 0 taken 68690 times.
✓ Branch 1 taken 1117 times.
69807 if(!((clk4+1)&63))
12673 {
12674 1117 int32_t d2=(zc_oldrand()%3)+1;
12675
12676
2/2
✓ Branch 0 taken 365 times.
✓ Branch 1 taken 752 times.
1117 if(d2>=left)
12677 {
12678 752 dir=d2;
12679 752 }
12680
12681
2/2
✓ Branch 0 taken 385 times.
✓ Branch 1 taken 732 times.
1117 if(dmisc1)
12682 {
12683
2/2
✓ Branch 0 taken 347 times.
✓ Branch 1 taken 38 times.
385 if(x<=40)
12684 {
12685 38 dir=right;
12686 38 }
12687
12688
1/2
✓ Branch 0 taken 385 times.
✗ Branch 1 not taken.
385 if(x>=104)
12689 {
12690 dir=left;
12691 }
12692 385 }
12693 else
12694 {
12695
2/2
✓ Branch 0 taken 711 times.
✓ Branch 1 taken 21 times.
732 if(x<=136)
12696 {
12697 21 dir=right;
12698 21 }
12699
12700
2/2
✓ Branch 0 taken 698 times.
✓ Branch 1 taken 34 times.
732 if(x>=200)
12701 {
12702 34 dir=left;
12703 34 }
12704 }
12705 1117 }
12706
12707
4/4
✓ Branch 0 taken 67907 times.
✓ Branch 1 taken 1900 times.
✓ Branch 2 taken 59366 times.
✓ Branch 3 taken 8541 times.
69807 if(clk4>=-1 && !((clk4+1)&7))
12708 {
12709
2/2
✓ Branch 0 taken 4546 times.
✓ Branch 1 taken 3995 times.
8541 if(dir==left)
12710 {
12711 4546 x-=1;
12712 4546 }
12713 else
12714 {
12715 3995 x+=1;
12716 }
12717 8541 }
12718
12719 69807 clk4=(clk4+1)%256;
12720
12721 69807 return enemy::animate(index);
12722 71899 }
12723
12724 72310 void eAquamentus::draw(BITMAP *dest)
12725 {
12726
2/2
✓ Branch 0 taken 44994 times.
✓ Branch 1 taken 27316 times.
72310 if(get_qr(qr_NEWENEMYTILES))
12727 {
12728 44994 xofs=(dmisc1?-16:0);
12729
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 44994 times.
✓ Branch 2 taken 18341 times.
✓ Branch 3 taken 26653 times.
44994 if ( do_animation ) tile=o_tile+((clk&24)>>2)+(clk3>-32?(clk3>0?40:80):0);
12730
12731
2/2
✓ Branch 0 taken 1312 times.
✓ Branch 1 taken 43682 times.
44994 if(dying)
12732 {
12733 1312 xofs=0;
12734 1312 enemy::draw(dest);
12735 1312 }
12736 else
12737 {
12738 43682 drawblock(dest,15);
12739 }
12740 44994 }
12741 else
12742 {
12743 27316 int32_t xblockofs=((dmisc1)?-16:16);
12744 27316 xofs=0;
12745
12746
4/4
✓ Branch 0 taken 26634 times.
✓ Branch 1 taken 682 times.
✓ Branch 2 taken 780 times.
✓ Branch 3 taken 25854 times.
27316 if(clk<0 || dying)
12747 {
12748 1462 enemy::draw(dest);
12749 1462 return;
12750 }
12751
1/2
✓ Branch 0 taken 25854 times.
✗ Branch 1 not taken.
25854 if ( do_animation )
12752 {
12753 // face (0=firing, 2=resting)
12754 25854 tile=o_tile+((clk3>0)?0:2);
12755 25854 enemy::draw(dest);
12756 // tail (
12757 25854 tile=o_tile+((clk&16)?1:3);
12758 25854 xofs=xblockofs;
12759 25854 enemy::draw(dest);
12760 // body
12761 25854 yofs+=16;
12762 25854 xofs=0;
12763 25854 tile=o_tile+((clk&16)?20:22);
12764 25854 enemy::draw(dest);
12765 25854 xofs=xblockofs;
12766 25854 tile=o_tile+((clk&16)?21:23);
12767 25854 enemy::draw(dest);
12768 25854 yofs-=16;
12769 25854 }
12770 else enemy::draw(dest);
12771 }
12772 72310 }
12773
12774 23834 bool eAquamentus::hit(weapon *w)
12775 {
12776
3/6
✓ Branch 0 taken 23834 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 23834 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 23834 times.
23834 if(!w->scriptcoldet || w->fallclk || w->drownclk) return false;
12777
12778
2/2
✓ Branch 0 taken 4201 times.
✓ Branch 1 taken 19633 times.
23834 switch(w->id)
12779 {
12780 case wBeam:
12781 case wRefBeam:
12782 case wMagic:
12783 4201 hit_height=32;
12784 4201 }
12785
12786
4/4
✓ Branch 0 taken 22740 times.
✓ Branch 1 taken 1094 times.
✓ Branch 2 taken 17546 times.
✓ Branch 3 taken 5194 times.
23834 bool ret = (dying || hclk>0) ? false : sprite::hit(w);
12787 23834 hit_height=16;
12788 23834 return ret;
12789
12790 23834 }
12791
12792 93 eGohma::eGohma(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk) // enemy((zfix)128,(zfix)48,Id,0)
12793 93 {
12794
12795
1/2
✓ Branch 0 taken 93 times.
✗ Branch 1 not taken.
93 if ( !(editorflags & ENEMY_FLAG5) )
12796 {
12797
1/2
✓ Branch 0 taken 93 times.
✗ Branch 1 not taken.
93 x = 128;
12798
1/2
✓ Branch 0 taken 93 times.
✗ Branch 1 not taken.
93 y = 48;
12799 93 }
12800 else { x = X; y = Y; }
12801
12802 93 Clk=Clk;
12803
2/4
✓ Branch 0 taken 93 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 93 times.
✗ Branch 3 not taken.
93 if(flags & guy_fade_flicker)
12804 {
12805 clk=0;
12806 superman = 1;
12807 fading=fade_flicker;
12808 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
12809 }
12810
3/4
✓ Branch 0 taken 93 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 51 times.
✓ Branch 3 taken 42 times.
93 else if(flags & guy_fade_instant)
12811 {
12812 42 clk=0;
12813 42 }
12814 93 hxofs=-16;
12815 93 hit_width=48;
12816 93 clk4=0;
12817
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 93 times.
✓ Branch 2 taken 93 times.
✗ Branch 3 not taken.
93 yofs=(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset)+1;
12818
1/2
✓ Branch 0 taken 93 times.
✗ Branch 1 not taken.
93 dir=zc_oldrand()%3+1;
12819
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 93 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
93 if (SIZEflags != 0) init_size_flags();;
12820
12821 //nets+5340;
12822 93 }
12823
12824 70891 bool eGohma::animate(int32_t index)
12825 {
12826
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 70891 times.
70891 if(switch_hooked) return enemy::animate(index);
12827
2/2
✓ Branch 0 taken 1226 times.
✓ Branch 1 taken 69665 times.
70891 if(dying)
12828 1226 return Dead(index);
12829
12830
2/2
✓ Branch 0 taken 69629 times.
✓ Branch 1 taken 36 times.
69665 if(fading)
12831 {
12832
2/2
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 1 times.
36 if(++clk4 > 60)
12833 {
12834 35 clk4=0;
12835 35 superman=0;
12836 35 fading=0;
12837 35 clk=0;
12838
12839 35 }
12840 1 else return enemy::animate(index);
12841 35 }
12842
12843
2/2
✓ Branch 0 taken 69314 times.
✓ Branch 1 taken 350 times.
69664 if(clk==0)
12844 {
12845
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 350 times.
350 if (ffcactivated) removearmosffc(ffcactivated-1);
12846 else
12847 {
12848
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 350 times.
350 removearmos(zc_max(x-16, 0_zf),y);
12849 350 did_armos = false;
12850 350 removearmos(x,y);
12851 350 did_armos = false;
12852
1/2
✓ Branch 0 taken 350 times.
✗ Branch 1 not taken.
350 removearmos(zc_min(x+16, 255_zf),y);
12853 }
12854 350 }
12855
12856
2/2
✓ Branch 0 taken 68878 times.
✓ Branch 1 taken 786 times.
69664 if(clk<0) return enemy::animate(index);
12857
12858 // Movement clk must be separate from animation clk because of the Clock item
12859
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 68878 times.
68878 if(!watch)
12860 68878 clk4++;
12861
12862
2/2
✓ Branch 0 taken 67846 times.
✓ Branch 1 taken 1032 times.
68878 if((clk4&63)==0)
12863 {
12864
2/2
✓ Branch 0 taken 546 times.
✓ Branch 1 taken 486 times.
1032 if(clk4&64)
12865 546 dir^=1;
12866 else
12867 486 dir=zc_oldrand()%3+1;
12868 1032 }
12869
12870
2/2
✓ Branch 0 taken 67761 times.
✓ Branch 1 taken 1117 times.
68878 if((clk&63)==3)
12871 {
12872
2/2
✓ Branch 0 taken 882 times.
✓ Branch 1 taken 235 times.
1117 switch(dmisc1)
12873 {
12874 case 1:
12875 235 addEwpn(x,y+2,z,wpn,3,wdp,left,getUID(), 0, fakez);
12876 235 addEwpn(x,y+2,z,wpn,3,wdp,8,getUID(), 0, fakez);
12877 235 addEwpn(x,y+2,z,wpn,3,wdp,right,getUID(), 0, fakez);
12878 235 sfx(wpnsfx(wpn),pan(int32_t(x)));
12879 235 break;
12880
12881 default:
12882
3/4
✓ Branch 0 taken 882 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 128 times.
✓ Branch 3 taken 754 times.
882 if(dmisc1 != 1 && dmisc1 != 2)
12883 {
12884 754 addEwpn(x,y+2,z,wpn,3,wdp,8,getUID(), 0, fakez);
12885 754 sfx(wpnsfx(wpn),pan(int32_t(x)));
12886 754 sfx(wpnsfx(wpn),pan(int32_t(x)));
12887 754 }
12888
12889 882 break;
12890 }
12891 1117 }
12892
12893
6/6
✓ Branch 0 taken 8027 times.
✓ Branch 1 taken 60851 times.
✓ Branch 2 taken 7611 times.
✓ Branch 3 taken 416 times.
✓ Branch 4 taken 5396 times.
✓ Branch 5 taken 2215 times.
68878 if((dmisc1 == 2)&& clk3>=16 && clk3<116)
12894 {
12895
2/2
✓ Branch 0 taken 290 times.
✓ Branch 1 taken 1925 times.
2215 if(!(clk3%8))
12896 {
12897 290 FireBreath(true);
12898 290 }
12899 2215 }
12900
12901
2/2
✓ Branch 0 taken 34399 times.
✓ Branch 1 taken 34479 times.
68878 if(clk4&1)
12902 34479 move((zfix)1);
12903
12904
2/2
✓ Branch 0 taken 68728 times.
✓ Branch 1 taken 150 times.
68878 if(++clk3>=400)
12905 150 clk3=0;
12906
12907 68878 return enemy::animate(index);
12908 70891 }
12909
12910 70889 void eGohma::draw(BITMAP *dest)
12911 {
12912 70889 tile=o_tile;
12913
12914
4/4
✓ Branch 0 taken 70103 times.
✓ Branch 1 taken 786 times.
✓ Branch 2 taken 1226 times.
✓ Branch 3 taken 68877 times.
70889 if(clk<0 || dying)
12915 {
12916 2012 enemy::drawzcboss(dest);
12917 2012 return;
12918 }
12919
12920
2/2
✓ Branch 0 taken 53472 times.
✓ Branch 1 taken 15405 times.
68877 if(get_qr(qr_NEWENEMYTILES))
12921 {
12922 ///if ( do_animation )
12923 //Yuck. Gohma can just not have this capability right now.
12924 // left side
12925 53472 xofs=-16;
12926 53472 flip=0;
12927 // if(clk&16) tile=180;
12928 // else { tile=182; flip=1; }
12929 53472 tile+=(3*((clk&48)>>4));
12930 53472 enemy::drawzcboss(dest);
12931
12932 // right side
12933 53472 xofs=16;
12934 // tile=(180+182)-tile;
12935 53472 tile=o_tile;
12936 53472 tile+=(3*((clk&48)>>4))+2;
12937 53472 enemy::drawzcboss(dest);
12938
12939 // body
12940 53472 xofs=0; //Gohma may need more adjustments for SIZEflags. -Z 14 Aug 2020
12941 53472 tile=o_tile;
12942
12943 // tile+=(3*((clk&24)>>3))+2;
12944
2/2
✓ Branch 0 taken 2975 times.
✓ Branch 1 taken 50497 times.
53472 if(clk3<16)
12945 2975 tile+=7;
12946
2/2
✓ Branch 0 taken 15890 times.
✓ Branch 1 taken 34607 times.
50497 else if(clk3<116)
12947 15890 tile+=10;
12948
2/2
✓ Branch 0 taken 2051 times.
✓ Branch 1 taken 32556 times.
34607 else if(clk3<132)
12949 2051 tile+=7;
12950 else
12951 32556 tile+=((clk3-132)&24)?4:1;
12952
12953 53472 enemy::drawzcboss(dest);
12954
12955 53472 }
12956 else
12957 {
12958 // left side
12959 15405 xofs=-16;
12960 15405 flip=0;
12961
12962
2/2
✓ Branch 0 taken 7615 times.
✓ Branch 1 taken 7790 times.
15405 if(!(clk&16))
12963 {
12964 7790 tile+=2;
12965 7790 flip=1;
12966 7790 }
12967
12968 15405 enemy::draw(dest);
12969
12970 // right side
12971 15405 tile=o_tile;
12972 15405 xofs=16;
12973
12974
2/2
✓ Branch 0 taken 7790 times.
✓ Branch 1 taken 7615 times.
15405 if((clk&16)) tile+=2;
12975
12976 // tile=(180+182)-tile;
12977 15405 enemy::draw(dest);
12978
12979 // body
12980 15405 tile=o_tile;
12981 15405 xofs=0;
12982
12983
2/2
✓ Branch 0 taken 912 times.
✓ Branch 1 taken 14493 times.
15405 if(clk3<16)
12984 912 tile+=4;
12985
2/2
✓ Branch 0 taken 4882 times.
✓ Branch 1 taken 9611 times.
14493 else if(clk3<116)
12986 4882 tile+=5;
12987
2/2
✓ Branch 0 taken 585 times.
✓ Branch 1 taken 9026 times.
9611 else if(clk3<132)
12988 585 tile+=4;
12989 9026 else tile+=((clk3-132)&8)?3:1;
12990
12991 15405 enemy::draw(dest);
12992
12993 }
12994 70889 }
12995
12996 578 int32_t eGohma::takehit(weapon *w, weapon* realweap)
12997 {
12998 578 int32_t wpnId = w->id;
12999 578 int32_t power = w->power;
13000 578 int32_t wpnx = w->x;
13001 578 int32_t wpnDir = w->dir;
13002 578 int32_t def = defenditemclassNew(wpnId, &power, w, realweap);
13003
13004
2/2
✓ Branch 0 taken 157 times.
✓ Branch 1 taken 421 times.
578 if(def < 0)
13005 {
13006
7/10
✗ Branch 0 not taken.
✓ Branch 1 taken 421 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 367 times.
✓ Branch 5 taken 54 times.
✓ Branch 6 taken 364 times.
✓ Branch 7 taken 3 times.
✓ Branch 8 taken 328 times.
✓ Branch 9 taken 36 times.
421 if(!((wpnDir==up || wpnDir==l_up || wpnDir==r_up) && abs(int32_t(x)-wpnx)<=8 && clk3>=16 && clk3<116))
13007 {
13008 93 sfx(WAV_CHINK,pan(int32_t(x)));
13009 93 return 1;
13010 }
13011 328 }
13012
13013 485 return enemy::takehit(w, realweap);
13014 578 }
13015
13016 327 eLilDig::eLilDig(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
13017 327 {
13018 327 count_enemy=(id==(id&0xFFF));
13019 //nets+4360+(((id&0xFF)-eDIGPUP2)*40);
13020
1/4
✓ Branch 0 taken 327 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
327 if (SIZEflags != 0) init_size_flags();;
13021 327 }
13022
13023 124050 bool eLilDig::animate(int32_t index)
13024 {
13025
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 124050 times.
124050 if(switch_hooked) return enemy::animate(index);
13026
2/2
✓ Branch 0 taken 4410 times.
✓ Branch 1 taken 119640 times.
124050 if(dying)
13027 4410 return Dead(index);
13028
13029
2/2
✓ Branch 0 taken 7105 times.
✓ Branch 1 taken 112535 times.
119640 if(clk==0)
13030 {
13031 7105 removearmos(x,y,ffcactivated);
13032 7105 }
13033
13034
2/2
✓ Branch 0 taken 80994 times.
✓ Branch 1 taken 38646 times.
119640 if(misc<=128)
13035 {
13036
2/2
✓ Branch 0 taken 1161 times.
✓ Branch 1 taken 37485 times.
38646 if(!(++misc&31))
13037 1161 step+=0.25;
13038 38646 }
13039
13040 119640 variable_walk_8(rate,homing,hrate,spw_floater);
13041 119640 return enemy::animate(index);
13042 124050 }
13043
13044 124268 void eLilDig::draw(BITMAP *dest)
13045 {
13046 124268 tile = o_tile;
13047 // tile = 160;
13048 124268 int32_t fdiv = frate/4;
13049
1/2
✓ Branch 0 taken 124268 times.
✗ Branch 1 not taken.
124268 int32_t efrate = fdiv == 0 ? 0 : clk/fdiv;
13050
2/2
✓ Branch 0 taken 91457 times.
✓ Branch 1 taken 32811 times.
124268 int32_t f2=get_qr(qr_NEWENEMYTILES)?
13051 124268 efrate:((clk>=(frate>>1))?1:0);
13052
13053
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 124268 times.
124268 if ( do_animation )
13054 {
13055
2/2
✓ Branch 0 taken 91457 times.
✓ Branch 1 taken 32811 times.
124268 if(get_qr(qr_NEWENEMYTILES))
13056 {
13057
9/9
✓ Branch 0 taken 11370 times.
✓ Branch 1 taken 10699 times.
✓ Branch 2 taken 10722 times.
✓ Branch 3 taken 12015 times.
✓ Branch 4 taken 10070 times.
✓ Branch 5 taken 9554 times.
✓ Branch 6 taken 8255 times.
✓ Branch 7 taken 10033 times.
✓ Branch 8 taken 8739 times.
91457 switch(dir-8) //directions get screwed up after 8. *shrug*
13058 {
13059 case up: //u
13060 11370 flip=0;
13061 11370 break;
13062
13063 case l_up: //d
13064 10699 flip=0;
13065 10699 tile+=4;
13066 10699 break;
13067
13068 case l_down: //l
13069 10722 flip=0;
13070 10722 tile+=8;
13071 10722 break;
13072
13073 case left: //r
13074 12015 flip=0;
13075 12015 tile+=12;
13076 12015 break;
13077
13078 case r_down: //ul
13079 10070 flip=0;
13080 10070 tile+=20;
13081 10070 break;
13082
13083 case down: //ur
13084 9554 flip=0;
13085 9554 tile+=24;
13086 9554 break;
13087
13088 case r_up: //dl
13089 8255 flip=0;
13090 8255 tile+=28;
13091 8255 break;
13092
13093 case right: //dr
13094 10033 flip=0;
13095 10033 tile+=32;
13096 10033 break;
13097 }
13098
13099 91457 tile+=f2;
13100 91457 }
13101 else
13102 {
13103 32811 tile+=(clk>=6)?1:0;
13104 }
13105 124268 }
13106
13107 124268 enemy::draw(dest);
13108 124268 }
13109
13110 80 eBigDig::eBigDig(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
13111 80 {
13112
1/2
✓ Branch 0 taken 80 times.
✗ Branch 1 not taken.
80 init_size_flags();
13113 80 }
13114
13115 29662 bool eBigDig::animate(int32_t index)
13116 {
13117
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29662 times.
29662 if(switch_hooked) return enemy::animate(index);
13118
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29662 times.
29662 if(dying)
13119 return Dead(index);
13120
13121
2/2
✓ Branch 0 taken 25558 times.
✓ Branch 1 taken 4104 times.
29662 if(clk==0)
13122 {
13123 4104 removearmos(x,y,ffcactivated);
13124 4104 }
13125
13126
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 29534 times.
✓ Branch 2 taken 64 times.
✓ Branch 3 taken 64 times.
29662 switch(misc)
13127 {
13128 case 0:
13129 29534 variable_walk_8(rate,homing,hrate,spw_floater,-8,-16,23,23);
13130 29534 break;
13131
13132 case 1:
13133 64 ++misc;
13134 64 break;
13135
13136 case 2:
13137
2/2
✓ Branch 0 taken 111 times.
✓ Branch 1 taken 64 times.
175 for(int32_t i=0; i<dmisc5; i++)
13138 {
13139 111 addenemy(x,y,dmisc1+0x1000,-15);
13140 111 }
13141
13142
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 64 times.
94 for(int32_t i=0; i<dmisc6; i++)
13143 {
13144 30 addenemy(x,y,dmisc2+0x1000,-15);
13145 30 }
13146
13147
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 64 times.
94 for(int32_t i=0; i<dmisc7; i++)
13148 {
13149 30 addenemy(x,y,dmisc3+0x1000,-15);
13150 30 }
13151
13152
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 64 times.
94 for(int32_t i=0; i<dmisc8; i++)
13153 {
13154 30 addenemy(x,y,dmisc4+0x1000,-15);
13155 30 }
13156
13157
2/2
✓ Branch 0 taken 62 times.
✓ Branch 1 taken 2 times.
64 if(itemguy) // Hand down the carried item
13158 {
13159 2 guycarryingitem = guys.Count()-1;
13160 2 ((enemy*)guys.spr(guycarryingitem))->itemguy = true;
13161 2 itemguy = false;
13162 2 }
13163
13164 64 stop_bgsfx(index);
13165
13166
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 64 times.
64 if(deadsfx > 0) sfx(deadsfx,pan(int32_t(x)));
13167
13168 64 return true;
13169 }
13170
13171 29598 return enemy::animate(index);
13172 29662 }
13173
13174 29658 void eBigDig::draw(BITMAP *dest)
13175 {
13176
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29658 times.
29658 if(anim!=aDIG)
13177 {
13178 update_enemy_frame();
13179 xofs-=8;
13180 yofs-=8;
13181 drawblock(dest,15);
13182 xofs+=8;
13183 yofs+=8;
13184 return;
13185 }
13186
13187 29658 tile = o_tile;
13188 29658 int32_t fdiv = frate/4;
13189
1/2
✓ Branch 0 taken 29658 times.
✗ Branch 1 not taken.
29658 int32_t efrate = fdiv == 0 ? 0 : clk/fdiv;
13190
13191
2/2
✓ Branch 0 taken 16161 times.
✓ Branch 1 taken 13497 times.
29658 int32_t f2=get_qr(qr_NEWENEMYTILES)?
13192 29658 efrate:((clk>=(frate>>1))?1:0);
13193
13194
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29658 times.
29658 if ( do_animation )
13195 {
13196
2/2
✓ Branch 0 taken 16161 times.
✓ Branch 1 taken 13497 times.
29658 if(get_qr(qr_NEWENEMYTILES))
13197 {
13198
9/9
✓ Branch 0 taken 1688 times.
✓ Branch 1 taken 1684 times.
✓ Branch 2 taken 2031 times.
✓ Branch 3 taken 1910 times.
✓ Branch 4 taken 2041 times.
✓ Branch 5 taken 2043 times.
✓ Branch 6 taken 1514 times.
✓ Branch 7 taken 1009 times.
✓ Branch 8 taken 2241 times.
16161 switch(dir-8) //directions get screwed up after 8. *shrug*
13199 {
13200 case up: //u
13201 1688 flip=0;
13202 1688 break;
13203
13204 case l_up: //d
13205 1684 flip=0;
13206 1684 tile+=8;
13207 1684 break;
13208
13209 case l_down: //l
13210 2031 flip=0;
13211 2031 tile+=40;
13212 2031 break;
13213
13214 case left: //r
13215 1910 flip=0;
13216 1910 tile+=48;
13217 1910 break;
13218
13219 case r_down: //ul
13220 2041 flip=0;
13221 2041 tile+=80;
13222 2041 break;
13223
13224 case down: //ur
13225 2043 flip=0;
13226 2043 tile+=88;
13227
13228 2043 break;
13229
13230 case r_up: //dl
13231 1514 flip=0;
13232 1514 tile+=120;
13233 1514 break;
13234
13235 case right: //dr
13236 2241 flip=0;
13237 2241 tile+=128;
13238 2241 break;
13239 }
13240
13241 16161 tile+=(f2*2);
13242 16161 }
13243 else
13244 {
13245 13497 tile+=(f2)?0:2;
13246 13497 flip=(clk&1)?1:0;
13247 }
13248 29658 }
13249
13250 29658 xofs-=8;
13251 29658 yofs-=8;
13252 29658 drawblock(dest,15);
13253 29658 xofs+=8;
13254 29658 yofs+=8;
13255 29658 }
13256
13257 869 int32_t eBigDig::takehit(weapon *w, weapon* realweap)
13258 {
13259 869 int32_t wpnId = w->id;
13260
13261
3/4
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 805 times.
✓ Branch 2 taken 64 times.
✗ Branch 3 not taken.
869 if(wpnId==wWhistle && misc==0)
13262 64 misc=1;
13263
13264 869 return 0;
13265 }
13266
13267 80 void eBigDig::init_size_flags()
13268 {
13269 80 SIZEflags = d->SIZEflags;
13270
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 80 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
80 if (((SIZEflags & OVERRIDE_TILE_WIDTH) != 0) && txsz > 0) { txsz = d->txsz; if (txsz > 1) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
13271 // al_trace("Enemy txsz:%i\n", txsz);
13272
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 80 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
80 if (((SIZEflags & OVERRIDE_TILE_HEIGHT) != 0) && tysz > 0) { tysz = d->tysz; if (tysz > 1) extend = 3; }
13273
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 80 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
80 if (((SIZEflags & OVERRIDE_HIT_WIDTH) != 0) && hit_width >= 0) hit_width = d->hxsz;
13274 80 else hit_width = 32;
13275
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 80 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
80 if (((SIZEflags & OVERRIDE_HIT_HEIGHT) != 0) && hit_height >= 0) hit_height = d->hysz;
13276 80 else hit_height = 32;
13277
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 80 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
80 if (((SIZEflags & OVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0) hzsz = d->hzsz;
13278 80 else hzsz = 16; // hard to jump.
13279
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 80 times.
80 if ((SIZEflags & OVERRIDE_HIT_X_OFFSET) != 0) hxofs = d->hxofs;
13280 80 else hxofs = -8;
13281
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 80 times.
80 if ((SIZEflags & OVERRIDE_HIT_Y_OFFSET) != 0) hyofs = d->hyofs;
13282 80 else hyofs = -8;
13283 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
13284
1/2
✓ Branch 0 taken 80 times.
✗ Branch 1 not taken.
80 if ((SIZEflags & OVERRIDE_DRAW_X_OFFSET) != 0) xofs = d->xofs;
13285
1/2
✓ Branch 0 taken 80 times.
✗ Branch 1 not taken.
80 if ((SIZEflags & OVERRIDE_DRAW_Y_OFFSET) != 0)
13286 {
13287 yofs = d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
13288 yofs += (get_qr(qr_OLD_DRAWOFFSET) ? playing_field_offset : original_playing_field_offset); //this offset fixes yofs not plaing properly. -Z
13289 }
13290
13291
1/2
✓ Branch 0 taken 80 times.
✗ Branch 1 not taken.
80 if ((SIZEflags & OVERRIDE_DRAW_Z_OFFSET) != 0) zofs = d->zofs;
13292 80 }
13293
13294 /*
13295 eGanon::eGanon(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
13296 {
13297 hxofs=hyofs=8;
13298 hzsz=16; //can't be jumped.
13299 clk2=70;
13300 misc=-1;
13301 mainguy=!getmapflag();
13302 }
13303
13304 bool eGanon::animate(int32_t index)
13305 {
13306 if(switch_hooked) return enemy::animate(index);
13307 if(dying)
13308
13309 return Dead(index);
13310
13311 if(clk==0)
13312 {
13313 removearmos(x,y,ffcactivated);
13314 }
13315
13316 switch(misc)
13317 {
13318 case -1:
13319 misc=0;
13320
13321 case 0:
13322 if(++clk2>72 && !(zc_oldrand()&3))
13323 {
13324 addEwpn(x,y,z,wpn,3,wdp,dir,getUID());
13325 sfx(wpnsfx(wpn),pan(int32_t(x)));
13326 clk2=0;
13327 }
13328
13329 Stunclk=0;
13330 constant_walk(rate,homing,spw_none);
13331 break;
13332
13333 case 1:
13334 case 2:
13335 if(--Stunclk<=0)
13336 {
13337 int32_t r=zc_oldrand();
13338
13339 if(r&1)
13340 {
13341 y=96;
13342
13343 if(r&2)
13344 x=160;
13345 else
13346 x=48;
13347
13348 if(tooclose(x,y,48))
13349 x=208-x;
13350 }
13351
13352 //if ( editorflags & ENEMY_FLAG15 && current_item_id(itype_amulet,false) >= 2 ) //visible to Amulet 2
13353 //{
13354 // loadpalset(9,pSprite(spBROWN)); //make Ganon visible?
13355 // }
13356 // else
13357 // {
13358 loadpalset(csBOSS,pSprite(d->bosspal));
13359 // }
13360 misc=0;
13361 }
13362
13363 break;
13364
13365 case 3:
13366 {
13367 if(hclk>0)
13368 break;
13369
13370 misc=4;
13371 clk=0;
13372 hxofs=1000;
13373 loadpalset(9,pSprite(spPILE));
13374 music_stop();
13375 stop_sfx(WAV_ROAR);
13376
13377 if(deadsfx>0) sfx(deadsfx,pan(int32_t(x)));
13378
13379 sfx(WAV_GANON);
13380 //Ganon's dustpile; fall in sideview. -Z
13381 item *dustpile = new item(x+8,y+8,(zfix)0,iPile,ipDUMMY,0);
13382 dustpile->linked_parent = eeGANON;
13383 setmapflag();
13384 //items.add(new item(x+8,y+8,(zfix)0,iPile,ipDUMMY,0));
13385 break;
13386 }
13387
13388 case 4:
13389 if(clk>=80)
13390 {
13391 misc=5;
13392
13393 if(getmapflag())
13394 {
13395 game->lvlitems[dlevel]|=liBOSS;
13396 //play_DmapMusic();
13397 playLevelMusic();
13398 return true;
13399 }
13400
13401 sfx(WAV_CLEARED);
13402 items.add(new item(x+8,y+8,(zfix)0,iBigTri,ipBIGTRI,0));
13403 setmapflag();
13404 }
13405
13406 break;
13407 }
13408
13409 //if ( editorflags & ENEMY_FLAG15 ) //visible to Amulet 2
13410 //{
13411 //if ( current_item_id(itype_amulet,false) >= 2 )
13412 //{
13413 /// loadpalset(9,pSprite(spBROWN)); //make Ganon visible?
13414 //}
13415 //}
13416
13417
13418 return enemy::animate(index);
13419 }
13420
13421
13422 int32_t eGanon::takehit(weapon *w, weapon* realweap)
13423 {
13424 //these are here to bypass compiler warnings about unused arguments
13425 int32_t wpnId = w->id;
13426 int32_t power = w->power;
13427 int32_t enemyHitWeapon = w->parentitem;
13428
13429 switch(misc)
13430 {
13431 case 0:
13432 {
13433 //if we're not using the editor defences, and Ganon isn't hit by a sword, return.
13434 if(wpnId!=wSword && !(editorflags & ENEMY_FLAG14))
13435 return 0;
13436
13437 //if we are not using the new defences, just reduce his HP
13438 if (!(editorflags & ENEMY_FLAG14))
13439 {
13440 hp-=power;
13441 if(hp>0)
13442 {
13443 misc=1;
13444 Stunclk=64;
13445 }
13446 else
13447 {
13448 loadpalset(csBOSS,pSprite(spBROWN));
13449 misc=2;
13450 Stunclk=284;
13451 hp=guysbuf[id&0xFFF].hp; //16*game->get_hero_dmgmult();
13452 }
13453
13454 sfx(WAV_EHIT,pan(int32_t(x)));
13455
13456 if(hitsfx>0) sfx(hitsfx,pan(int32_t(x)));
13457
13458 return 1;
13459 }
13460 //otherwise, resolve his defence.
13461 else
13462 {
13463 int32_t def = enemy::takehit(w,realweap); //This works, but it instantly kills him if it does enough damage.
13464 if(hp>0)
13465 {
13466 misc=1;
13467 Stunclk=64;
13468 }
13469 else
13470 {
13471 loadpalset(csBOSS,pSprite(spBROWN));
13472 misc=2;
13473 Stunclk=284;
13474 hp=guysbuf[id&0xFFF].hp; //16*game->get_hero_dmgmult();
13475 }
13476
13477 sfx(WAV_EHIT,pan(int32_t(x)));
13478
13479 if(hitsfx>0) sfx(hitsfx,pan(int32_t(x)));
13480
13481
13482 return 1;
13483 }
13484 }
13485 case 2:
13486 {
13487 if
13488 (
13489 ( dmisc14 > 0 && !enemyHitWeapon == dmisc14 ) //special weapon needed to kill ganon specified in editor
13490 || //or nothing specified, use silver arrows+
13491 ( dmisc14 <= 0 && (wpnId!=wArrow || (enemyHitWeapon>-1 ? itemsbuf[enemyHitWeapon].power : current_item_power(itype_arrow))<4))
13492 )
13493 return 0;
13494 {
13495 misc=3;
13496 hclk=81;
13497 loadpalset(9,pSprite(spBROWN));
13498 return 1;
13499 }
13500
13501 }
13502 }
13503
13504 return 0;
13505 }
13506
13507 void eGanon::draw(BITMAP *dest)
13508 {
13509 switch(misc)
13510 {
13511 case 0:
13512 if((clk&3)==3)
13513 tile=(zc_oldrand()%5)*2+o_tile;
13514
13515 if(db!=999)
13516 break;
13517
13518 case 2:
13519 if(Stunclk<64 && (Stunclk&1) )
13520 {
13521 if
13522 (
13523 ( (editorflags & ENEMY_FLAG1) && current_item_power(itype_amulet) >= 2 && (editorflags & ENEMY_FLAG15) )
13524 ||
13525 ( (editorflags & ENEMY_FLAG2) && (game->item[dmisc13]) && (editorflags & ENEMY_FLAG15) )
13526 )
13527 {
13528 goto ganon_draw; //draw his weapons if we can see him
13529 }
13530 break;
13531 }
13532
13533 case -1:
13534 tile=o_tile;
13535
13536 //fall through
13537 case 1:
13538 case 3:
13539 ganon_draw:
13540 drawblock(dest,15);
13541 break;
13542
13543 case 4:
13544 draw_guts(dest);
13545 draw_flash(dest);
13546 break;
13547 }
13548
13549 if ( editorflags & ENEMY_FLAG1 ) //visible to Amulet 2
13550 {
13551 if
13552 (
13553 ( (editorflags & ENEMY_FLAG1) && current_item_power(itype_amulet) >= 2 && (editorflags & ENEMY_FLAG15) )
13554 ||
13555 ( (editorflags & ENEMY_FLAG2) && (game->item[dmisc13]) && (editorflags & ENEMY_FLAG15) )
13556 )
13557 {
13558 draw_guts(dest); //makes his shots visible, but not him
13559 draw_flash(dest);
13560 }
13561 }
13562 }
13563
13564 void eGanon::draw_guts(BITMAP *dest)
13565 {
13566 int32_t c = zc_min(clk>>3,8);
13567 tile = clk<24 ? 74 : 75;
13568 overtile16(dest,tile,x+8,y+c+playing_field_offset,9,0);
13569 overtile16(dest,tile,x+8,y+16-c+playing_field_offset,9,0);
13570 overtile16(dest,tile,x+c,y+8+playing_field_offset,9,0);
13571 overtile16(dest,tile,x+16-c,y+8+playing_field_offset,9,0);
13572 overtile16(dest,tile,x+c,y+c+playing_field_offset,9,0);
13573 overtile16(dest,tile,x+16-c,y+c+playing_field_offset,9,0);
13574 overtile16(dest,tile,x+c,y+16-c+playing_field_offset,9,0);
13575 overtile16(dest,tile,x+16-c,y+16-c+playing_field_offset,9,0);
13576 }
13577
13578 void eGanon::draw_flash(BITMAP *dest)
13579 {
13580
13581 int32_t c = clk-(clk>>2);
13582 cs = (frame&3)+6;
13583 overtile16(dest,194,x+8,y+8-clk+playing_field_offset,cs,0);
13584 overtile16(dest,194,x+8,y+8+clk+playing_field_offset,cs,2);
13585 overtile16(dest,195,x+8-clk,y+8+playing_field_offset,cs,0);
13586 overtile16(dest,195,x+8+clk,y+8+playing_field_offset,cs,1);
13587 overtile16(dest,196,x+8-c,y+8-c+playing_field_offset,cs,0);
13588 overtile16(dest,196,x+8+c,y+8-c+playing_field_offset,cs,1);
13589 overtile16(dest,196,x+8-c,y+8+c+playing_field_offset,cs,2);
13590 overtile16(dest,196,x+8+c,y+8+c+playing_field_offset,cs,3);
13591 }
13592 */
13593
13594 13 eGanon::eGanon(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
13595 13 {
13596 13 hxofs=hyofs=8;
13597
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if (editorflags & ENEMY_FLAG3)
13598 {
13599 hxofs = 4;
13600 hyofs = 4;
13601 hit_width = 24;
13602 hit_height = 24;
13603 SIZEflags|=OVERRIDE_HIT_WIDTH;
13604 SIZEflags|=OVERRIDE_HIT_HEIGHT;
13605 }
13606 13 hzsz=16; //can't be jumped.
13607 13 clk2=70;
13608 13 misc=-1;
13609
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
✓ Branch 2 taken 13 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 13 times.
✗ Branch 5 not taken.
13 mainguy=(!getmapflag((currscr < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM) || (tmpscr->flags9&fBELOWRETURN));
13610 13 }
13611
13612 18254 bool eGanon::animate(int32_t index) //DO NOT ADD a check for do_animation to this version of GANON!! -Z
13613 {
13614
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18254 times.
18254 if(dying)
13615
13616 return Dead(index);
13617
13618
2/2
✓ Branch 0 taken 18182 times.
✓ Branch 1 taken 72 times.
18254 if(clk==0)
13619 {
13620 72 removearmos(x,y,ffcactivated);
13621 72 }
13622
13623
6/7
✓ Branch 0 taken 3607 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12680 times.
✓ Branch 3 taken 13 times.
✓ Branch 4 taken 984 times.
✓ Branch 5 taken 960 times.
✓ Branch 6 taken 10 times.
18254 switch(misc)
13624 {
13625 case -1:
13626 13 misc=0;
13627 [[fallthrough]];
13628 case 0:
13629
4/4
✓ Branch 0 taken 708 times.
✓ Branch 1 taken 11985 times.
✓ Branch 2 taken 535 times.
✓ Branch 3 taken 173 times.
12693 if(++clk2>72 && !(zc_oldrand()&3))
13630 {
13631 173 addEwpn(x,y,z,wpn,3,wdp,dir,getUID(), 0, fakez);
13632 173 sfx(wpnsfx(wpn),pan(int32_t(x)));
13633 173 clk2=0;
13634 173 }
13635
13636 12693 Stunclk=0;
13637 12693 constant_walk(rate,homing,spw_none);
13638 12693 break;
13639
13640 case 1:
13641 case 2:
13642
2/2
✓ Branch 0 taken 3566 times.
✓ Branch 1 taken 41 times.
3607 if(--Stunclk<=0)
13643 {
13644 41 int32_t r=zc_oldrand();
13645
13646
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 17 times.
41 if(r&1)
13647 {
13648 17 y=96;
13649
13650
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 11 times.
17 if(r&2)
13651 6 x=160;
13652 else
13653 11 x=48;
13654
13655
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 8 times.
17 if(tooclose(x,y,48))
13656 8 x=208-x;
13657 17 }
13658
13659 41 loadpalset(csBOSS,pSprite(d->bosspal));
13660 41 misc=0;
13661 41 }
13662
13663 3607 break;
13664
13665 case 3:
13666 {
13667
2/2
✓ Branch 0 taken 972 times.
✓ Branch 1 taken 12 times.
984 if(hclk>0)
13668 972 break;
13669
13670 12 misc=4;
13671 12 clk=0;
13672 12 hxofs=1000;
13673 12 loadpalset(9,pSprite(spPILE));
13674 12 music_stop();
13675 12 stop_sfx(WAV_ROAR);
13676
13677
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(deadsfx>0) sfx(deadsfx,pan(int32_t(x)));
13678
13679 12 sfx(WAV_GANON);
13680 //Ganon's dustpile; fall in sideview. -Z
13681 //item *dustpile = new item(x+8,y+8,(zfix)0,iPile,ipDUMMY,0);
13682 //dustpile->miscellaneous[31] = eeGANON;
13683
6/12
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 12 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 12 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 12 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 12 times.
✗ Branch 11 not taken.
12 items.add(new item(x+8,y+8,(zfix)0,iPile,ipDUMMY,0));
13684 12 item *dustpile = NULL;
13685 //dustpile = (item *)items.spr(items.Count() - 1)->getUID();
13686 12 dustpile = (item *)items.spr(items.Count() - 1);
13687 12 dustpile->linked_parent = eeGANON; //was miscellaneous[31]
13688 //setmapflag(); //Could be why the Triforce doesn't drop. Disabling this now. -Z ( 6th March, 2019 )
13689 //items.add(new item(x+8,y+8,(zfix)0,iPile,ipDUMMY,0));
13690 12 break;
13691 }
13692
13693 case 4:
13694
2/2
✓ Branch 0 taken 948 times.
✓ Branch 1 taken 12 times.
960 if(clk>=80)
13695 {
13696 12 misc=5;
13697
13698 //game->lvlitems[dlevel]|=liBOSS;
13699
13700 12 sfx(WAV_CLEARED);
13701 //Add the big TF over the ashes!
13702
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 12 times.
36 for(word q = 0; q < items.Count(); q++)
13703 {
13704 24 item *ashes = (item*)items.spr(q);
13705
3/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✓ Branch 3 taken 12 times.
24 if ( ashes->linked_parent == eeGANON && (ashes->pickup&ipDUMMY))
13706 {
13707 //Z_scripterrlog("Found correct dustpile!\n");
13708
4/8
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 12 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 12 times.
✗ Branch 7 not taken.
12 items.add(new item(ashes->x,ashes->y,(zfix)0,iBigTri,ipBIGTRI,0));
13709 12 item *bigtriforce = NULL;
13710 12 bigtriforce = (item *)items.spr(items.Count() - 1);
13711 12 bigtriforce->linked_parent = eeGANON;
13712 12 }
13713 24 }
13714 //setmapflag((currscr < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM);
13715 //game->lvlitems[dlevel]|=liBOSS; // if we had more rule bits, we could mark him dead so that he does not respawn. -Z
13716 12 }
13717
13718 960 break;
13719 10 case 5: return true;
13720 }
13721
13722 18244 return enemy::animate(index);
13723 18254 }
13724
13725
13726 964 int32_t eGanon::takehit(weapon *w, weapon* realweap)
13727 {
13728 //these are here to bypass compiler warnings about unused arguments
13729 964 int32_t wpnId = w->id;
13730 964 int32_t power = w->power;
13731 964 int32_t enemyHitWeapon = w->parentitem;
13732
13733
3/3
✓ Branch 0 taken 714 times.
✓ Branch 1 taken 84 times.
✓ Branch 2 taken 166 times.
964 switch(misc)
13734 {
13735 case 0:
13736
2/2
✓ Branch 0 taken 31 times.
✓ Branch 1 taken 53 times.
84 if(wpnId!=wSword)
13737 31 return 0;
13738
13739 53 hp-=power;
13740
13741
2/2
✓ Branch 0 taken 41 times.
✓ Branch 1 taken 12 times.
53 if(hp>0)
13742 {
13743 41 misc=1;
13744 41 Stunclk=64;
13745 41 }
13746 else
13747 {
13748 12 loadpalset(csBOSS,pSprite(spBROWN));
13749 12 misc=2;
13750 12 Stunclk=284;
13751 12 hp=guysbuf[id&0xFFF].hp; //16*game->get_hero_dmgmult();
13752 }
13753
13754 53 sfx(WAV_EHIT,pan(int32_t(x)));
13755
13756
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 53 times.
53 if(hitsfx>0) sfx(hitsfx,pan(int32_t(x)));
13757
13758 53 return 1;
13759
13760 case 2:
13761
4/6
✓ Branch 0 taken 154 times.
✓ Branch 1 taken 12 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 12 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 12 times.
166 if(wpnId!=wArrow || (enemyHitWeapon>-1 ? itemsbuf[enemyHitWeapon].power : current_item_power(itype_arrow))<4)
13762 154 return 0;
13763
13764 12 misc=3;
13765 12 hclk=81;
13766 12 loadpalset(9,pSprite(spBROWN));
13767 12 return 1;
13768 }
13769
13770 714 return 0;
13771 964 }
13772
13773 20776 void eGanon::draw(BITMAP *dest)
13774 {
13775
6/6
✓ Branch 0 taken 3608 times.
✓ Branch 1 taken 10 times.
✓ Branch 2 taken 983 times.
✓ Branch 3 taken 2535 times.
✓ Branch 4 taken 12680 times.
✓ Branch 5 taken 960 times.
20776 switch(misc)
13776 {
13777 case 0:
13778
2/2
✓ Branch 0 taken 9511 times.
✓ Branch 1 taken 3169 times.
12680 if((clk&3)==3)
13779 3169 tile=(zc_oldrand()%5)*2+o_tile;
13780
13781
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 12680 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
12680 if ( (editorflags & ENEMY_FLAG1) && current_item_power(itype_amulet) >= 2 ) //ganon is visible to level 2 amulet
13782 {
13783
13784 if ( editorflags & ENEMY_FLAG16 ) //draw cloaked
13785 {
13786 int odraw = drawstyle;
13787 drawstyle = 2;
13788 drawblock(dest,15);
13789 drawstyle = odraw;
13790 }
13791 else
13792 {
13793 drawblock(dest,15);
13794 }
13795 break;
13796
13797 }
13798
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 12680 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
12680 else if ( (editorflags & ENEMY_FLAG2) && (game->item[dmisc13]) )
13799 {
13800 if ( editorflags & ENEMY_FLAG16 ) //draw cloaked
13801 {
13802 int odraw = drawstyle;
13803 drawstyle = 2;
13804 drawblock(dest,15);
13805 drawstyle = odraw;
13806 }
13807 else
13808 {
13809 drawblock(dest,15);
13810 }
13811 break;
13812 }
13813
1/2
✓ Branch 0 taken 12680 times.
✗ Branch 1 not taken.
12680 if(db!=999)
13814 12680 break;
13815 [[fallthrough]];
13816 case 2:
13817
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 983 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
983 if(Stunclk<64 && (Stunclk&1))
13818 break;
13819 [[fallthrough]];
13820 case -1:
13821 3518 tile=o_tile;
13822
13823 [[fallthrough]];
13824 case 1:
13825 case 3:
13826 7126 drawblock(dest,15);
13827 7126 break;
13828
13829 case 4:
13830 960 draw_guts(dest);
13831 960 draw_flash(dest);
13832 960 break;
13833 }
13834 20776 }
13835
13836 960 void eGanon::draw_guts(BITMAP *dest)
13837 {
13838
2/2
✓ Branch 0 taken 756 times.
✓ Branch 1 taken 204 times.
960 int32_t c = zc_min(clk>>3,8);
13839 960 tile = clk<24 ? 74 : 75;
13840 960 overtile16(dest,tile,x+8,y+c+playing_field_offset,9,0);
13841 960 overtile16(dest,tile,x+8,y+16-c+playing_field_offset,9,0);
13842 960 overtile16(dest,tile,x+c,y+8+playing_field_offset,9,0);
13843 960 overtile16(dest,tile,x+16-c,y+8+playing_field_offset,9,0);
13844 960 overtile16(dest,tile,x+c,y+c+playing_field_offset,9,0);
13845 960 overtile16(dest,tile,x+16-c,y+c+playing_field_offset,9,0);
13846 960 overtile16(dest,tile,x+c,y+16-c+playing_field_offset,9,0);
13847 960 overtile16(dest,tile,x+16-c,y+16-c+playing_field_offset,9,0);
13848 960 }
13849
13850 960 void eGanon::draw_flash(BITMAP *dest)
13851 {
13852
13853 960 int32_t c = clk-(clk>>2);
13854 960 cs = (frame&3)+6;
13855 960 overtile16(dest,194,x+8,y+8-clk+playing_field_offset,cs,0);
13856 960 overtile16(dest,194,x+8,y+8+clk+playing_field_offset,cs,2);
13857 960 overtile16(dest,195,x+8-clk,y+8+playing_field_offset,cs,0);
13858 960 overtile16(dest,195,x+8+clk,y+8+playing_field_offset,cs,1);
13859 960 overtile16(dest,196,x+8-c,y+8-c+playing_field_offset,cs,0);
13860 960 overtile16(dest,196,x+8+c,y+8-c+playing_field_offset,cs,1);
13861 960 overtile16(dest,196,x+8-c,y+8+c+playing_field_offset,cs,2);
13862 960 overtile16(dest,196,x+8+c,y+8+c+playing_field_offset,cs,3);
13863 960 }
13864
13865 15 void getBigTri(int32_t id2)
13866 {
13867 /*
13868 *************************
13869 * BIG TRIFORCE SEQUENCE *
13870 *************************
13871 0 BIGTRI out, WHITE flash in
13872 4 WHITE flash out, PILE cset white
13873 8 WHITE in
13874 ...
13875 188 WHITE out
13876 191 PILE cset red
13877 200 top SHUTTER opens
13878 209 bottom SHUTTER opens
13879 */
13880 15 sfx(itemsbuf[id2].playsound);
13881 15 guys.clear();
13882
13883
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15 times.
15 if(itemsbuf[id2].flags & item_gamedata)
13884 {
13885 game->lvlitems[dlevel]|=liTRIFORCE;
13886 }
13887
13888
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15 times.
15 setmapflag((currscr < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM);
13889
13890 15 draw_screen(tmpscr);
13891
13892
4/4
✓ Branch 0 taken 15 times.
✓ Branch 1 taken 2880 times.
✓ Branch 2 taken 15 times.
✓ Branch 3 taken 2880 times.
2895 for(int32_t f=0; f<24*8 && !Quit; f++)
13893 {
13894
2/2
✓ Branch 0 taken 2865 times.
✓ Branch 1 taken 15 times.
2880 if(f==4)
13895 {
13896
2/2
✓ Branch 0 taken 225 times.
✓ Branch 1 taken 15 times.
240 for(int32_t i=1; i<16; i++)
13897 {
13898 225 RAMpal[CSET(9)+i]=_RGB(255,255,255);
13899 225 }
13900 15 }
13901
13902
2/2
✓ Branch 0 taken 2520 times.
✓ Branch 1 taken 360 times.
2880 if((f&7)==0)
13903 {
13904
2/2
✓ Branch 0 taken 1080 times.
✓ Branch 1 taken 360 times.
1440 for(int32_t cs=2; cs<5; cs++)
13905 {
13906
2/2
✓ Branch 0 taken 16200 times.
✓ Branch 1 taken 1080 times.
17280 for(int32_t i=1; i<16; i++)
13907 {
13908 16200 RAMpal[CSET(cs)+i]=_RGB(255,255,255);
13909 16200 }
13910 1080 }
13911
13912 360 refreshpal=true;
13913 360 }
13914
13915
2/2
✓ Branch 0 taken 2520 times.
✓ Branch 1 taken 360 times.
2880 if((f&7)==4)
13916 {
13917
1/2
✓ Branch 0 taken 360 times.
✗ Branch 1 not taken.
360 if(currscr<128) loadlvlpal(DMaps[currdmap].color);
13918 else loadlvlpal(0xB);
13919 360 }
13920
13921
2/2
✓ Branch 0 taken 2865 times.
✓ Branch 1 taken 15 times.
2880 if(f==191)
13922 {
13923 15 loadpalset(9,pSprite(spPILE));
13924 15 }
13925
13926 2880 advanceframe(true);
13927 2880 }
13928
13929 //play_DmapMusic();
13930 15 playLevelMusic();
13931
13932
3/4
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 13 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
15 if(itemsbuf[id2].flags & item_flag1 && currscr < 128)
13933 {
13934 2 Hero.dowarp(1,0); //side warp
13935 2 }
13936 15 }
13937
13938 //! No. I am not adding SIZEflags to Moldorm and Lanmola. -Z 12 Aug 2020
13939 618 eMoldorm::eMoldorm(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
13940 618 {
13941
1/2
✓ Branch 0 taken 618 times.
✗ Branch 1 not taken.
618 if( !(editorflags & ENEMY_FLAG5) )
13942 {
13943
1/2
✓ Branch 0 taken 618 times.
✗ Branch 1 not taken.
618 x=128;
13944
1/2
✓ Branch 0 taken 618 times.
✗ Branch 1 not taken.
618 y=48;
13945 618 }
13946 //else { x = X; y = Y; }
13947
1/2
✓ Branch 0 taken 618 times.
✗ Branch 1 not taken.
618 dir=(zc_oldrand()&7)+8;
13948 618 superman=1;
13949 618 fading=fade_invisible;
13950 618 hxofs=1000;
13951 618 segcnt=clk;
13952 618 segid=Id|0x1000;
13953 618 clk=0;
13954
1/2
✓ Branch 0 taken 618 times.
✗ Branch 1 not taken.
618 id=guys.Count();
13955
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 618 times.
✓ Branch 2 taken 618 times.
✗ Branch 3 not taken.
618 yofs=(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
13956 618 tile=o_tile;
13957 618 hitdir = -1;
13958 618 stickclk = 0;
13959
13960 /*
13961 if (get_qr(qr_NEWENEMYTILES))
13962 {
13963 tile=nets+1220;
13964 }
13965 else
13966 {
13967 tile=57;
13968 }
13969 */
13970 618 }
13971
13972 244844 bool eMoldorm::animate(int32_t index)
13973 {
13974
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 244844 times.
244844 if(switch_hooked) return enemy::animate(index);
13975 244844 int32_t max_y = isdungeon() ? 100 : 100+28; //warning: Ugly hack. -Z
13976
2/2
✓ Branch 0 taken 216369 times.
✓ Branch 1 taken 28475 times.
244844 if ( y > (max_y) )
13977 {
13978 28475 ++stickclk; //Keep Moldorm from pacinn the bottom row or leaving the screen via the bottom edge. -Z 8th Sept, 2019
13979 //Z_scripterrlog("Stickclk is %d\n", stickclk);
13980 28475 }
13981
2/2
✓ Branch 0 taken 244282 times.
✓ Branch 1 taken 562 times.
244844 if ( stickclk > 45 )
13982 {
13983 562 stickclk = 0;
13984 562 newdir_8_old(rate,homing,spw_floater); //chage dir to keep from getting stuck.
13985 562 }
13986
13987
13988
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 244844 times.
244844 if(clk==0)
13989 {
13990 244844 removearmos(x,y,ffcactivated);
13991 244844 }
13992
13993
2/2
✓ Branch 0 taken 2451 times.
✓ Branch 1 taken 242393 times.
244844 if(clk2)
13994 {
13995
2/2
✓ Branch 0 taken 2322 times.
✓ Branch 1 taken 129 times.
2451 if(--clk2 == 0)
13996 {
13997
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 129 times.
129 if(flags&guy_never_return)
13998 129 never_return(index);
13999
14000
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 129 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
129 if(!dmisc2 || (editorflags & ENEMY_FLAG6))
14001 129 leave_item();
14002
14003 129 stop_bgsfx(index);
14004 129 return true;
14005 }
14006 2322 }
14007 else
14008 {
14009
1/2
✓ Branch 0 taken 242393 times.
✗ Branch 1 not taken.
242393 if(stunclk>0)
14010 stunclk=0;
14011 242393 constant_walk_8_old(rate,homing,spw_floater);
14012
14013
14014 242393 misc=dir;
14015
14016 // If any higher-numbered segments were killed, segcnt can be too high,
14017 // leading to a crash
14018
1/2
✓ Branch 0 taken 242393 times.
✗ Branch 1 not taken.
242393 if(index+segcnt>=guys.Count())
14019 segcnt=guys.Count()-index-1;
14020
14021
2/2
✓ Branch 0 taken 242393 times.
✓ Branch 1 taken 1122281 times.
1364674 for(int32_t i=index+1; i<index+segcnt+1; i++)
14022 {
14023 1122281 enemy* segment=((enemy*)guys.spr(i));
14024
14025 // More validation - if segcnt was wrong, this may not
14026 // actually be a Moldorm segment
14027
1/2
✓ Branch 0 taken 1122281 times.
✗ Branch 1 not taken.
1122281 if(segment->id!=segid)
14028 {
14029 segcnt=i-index-1;
14030 break;
14031 }
14032
14033
2/2
✓ Branch 0 taken 879612 times.
✓ Branch 1 taken 242669 times.
1122281 if(i==index+1)
14034 {
14035 242669 x=segment->x;
14036 242669 y=segment->y;
14037 242669 }
14038
14039 1122281 segment->o_tile=tile; //I refuse to fuck with adding scripttile to segmented enemies. -Z
14040 //Script your own blasted segmented bosses!! -Z
14041 1122281 segment->parent_script_UID = this->script_UID;
14042
4/4
✓ Branch 0 taken 242393 times.
✓ Branch 1 taken 879888 times.
✓ Branch 2 taken 24660 times.
✓ Branch 3 taken 217733 times.
1122281 if((i==index+segcnt)&&(i!=index+1)) //tail
14043 {
14044 217733 segment->dummy_int[1]=2;
14045 217733 }
14046 else
14047 {
14048 904548 segment->dummy_int[1]=1;
14049 }
14050
14051
2/2
✓ Branch 0 taken 879612 times.
✓ Branch 1 taken 242669 times.
1122281 if(i==index+1) //head
14052 {
14053 242669 segment->dummy_int[1]=0;
14054 242669 }
14055
14056
2/2
✓ Branch 0 taken 1121265 times.
✓ Branch 1 taken 1016 times.
1122281 if(segment->hp <= 0)
14057 {
14058 1016 int32_t offset=1;
14059
14060
2/2
✓ Branch 0 taken 1016 times.
✓ Branch 1 taken 1480 times.
2496 for(int32_t j=i; j<index+segcnt; j++)
14061 {
14062 // Triple-check
14063
1/2
✓ Branch 0 taken 1480 times.
✗ Branch 1 not taken.
1480 if(((enemy*)guys.spr(j+1))->id!=segid)
14064 {
14065 segcnt=j-index+1; // Add 1 because of --segcnt below
14066 break;
14067 }
14068 1480 zc_swap(((enemy*)guys.spr(j))->hp,((enemy*)guys.spr(j+1))->hp);
14069 1480 zc_swap(((enemy*)guys.spr(j))->hclk,((enemy*)guys.spr(j+1))->hclk);
14070 1480 }
14071
14072 1016 segment->hclk=33;
14073 1016 --segcnt;
14074 1016 --i; // Recheck the same index in case multiple segments died at once
14075 1016 }
14076 1122281 }
14077
14078
2/2
✓ Branch 0 taken 129 times.
✓ Branch 1 taken 242264 times.
242393 if(segcnt==0)
14079 {
14080 129 clk2=19;
14081
14082 129 x=guys.spr(index+1)->x;
14083 129 y=guys.spr(index+1)->y;
14084 129 }
14085 }
14086
14087 244715 return false;
14088 244844 }
14089
14090 3150 esMoldorm::esMoldorm(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
14091 3150 {
14092
1/2
✓ Branch 0 taken 3150 times.
✗ Branch 1 not taken.
3150 if( !(editorflags & ENEMY_FLAG5) )
14093 {
14094
1/2
✓ Branch 0 taken 3150 times.
✗ Branch 1 not taken.
3150 x=128;
14095
1/2
✓ Branch 0 taken 3150 times.
✗ Branch 1 not taken.
3150 y=48;
14096 3150 }
14097
14098
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3150 times.
✓ Branch 2 taken 3150 times.
✗ Branch 3 not taken.
3150 yofs=(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
14099 3150 hyofs=4;
14100 3150 hit_width=hit_height=8;
14101 3150 hxofs=1000;
14102 3150 mainguy=count_enemy=false;
14103 3150 parentclk = 0;
14104 3150 bgsfx=-1;
14105
2/4
✓ Branch 0 taken 3150 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3150 times.
✗ Branch 3 not taken.
3150 flags&=~guy_never_return;
14106 //deadsfx = WAV_EDEAD;
14107 3150 isCore = false;
14108 3150 }
14109
14110 1138024 bool esMoldorm::animate(int32_t index)
14111 {
14112
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1138024 times.
1138024 if(switch_hooked) return enemy::animate(index);
14113 // Shouldn't be possible, but better to be sure
14114
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1138024 times.
1138024 if(index==0)
14115 dying=true;
14116
14117
2/2
✓ Branch 0 taken 15743 times.
✓ Branch 1 taken 1122281 times.
1138024 if(dying)
14118 {
14119
1/2
✓ Branch 0 taken 15743 times.
✗ Branch 1 not taken.
15743 if(!dmisc2)
14120 15743 item_set=0;
14121
14122 15743 return Dead(index);
14123 }
14124
14125
2/2
✓ Branch 0 taken 105077 times.
✓ Branch 1 taken 1017204 times.
1122281 if(clk>=0)
14126 {
14127 1017204 hxofs=4;
14128 1017204 step=((enemy*)guys.spr(index-1))->step;
14129
14130
2/2
✓ Branch 0 taken 70455 times.
✓ Branch 1 taken 946749 times.
1017204 if(parentclk == 0)
14131 {
14132 70455 misc=dir;
14133 70455 dir=((enemy*)guys.spr(index-1))->misc;
14134 //do alignment, as in parent's animation :-/ -DD
14135 70455 x.doFloor();
14136 70455 y.doFloor();
14137 70455 }
14138
14139
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1017204 times.
1017204 if(step)
14140 1017204 parentclk=(parentclk+1)%((int32_t)(8.0/step));
14141
14142
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1017204 times.
1017204 if(!watch)
14143 {
14144 1017204 sprite::move(step);
14145 1017204 }
14146 1017204 }
14147
14148 1122281 return enemy::animate(index);
14149 1138024 }
14150
14151 2683 int32_t esMoldorm::takehit(weapon *w, weapon* realweap)
14152 {
14153
2/2
✓ Branch 0 taken 2230 times.
✓ Branch 1 taken 453 times.
2683 if(enemy::takehit(w,realweap))
14154 2230 return (w->id==wSBomb) ? 1 : 2; // force it to wait a frame before checking sword attacks again
14155
14156 453 return 0;
14157 2683 }
14158
14159 1155313 void esMoldorm::draw(BITMAP *dest)
14160 {
14161 1155313 tile=o_tile;
14162 1155313 int32_t fdiv = frate/4;
14163
1/2
✓ Branch 0 taken 1155313 times.
✗ Branch 1 not taken.
1155313 int32_t efrate = fdiv == 0 ? 0 : clk/fdiv;
14164
14165
2/2
✓ Branch 0 taken 1043930 times.
✓ Branch 1 taken 111383 times.
1155313 int32_t f2=get_qr(qr_NEWENEMYTILES)?
14166 1155313 efrate:((clk>=(frate>>1))?1:0);
14167
14168
2/2
✓ Branch 0 taken 111383 times.
✓ Branch 1 taken 1043930 times.
1155313 if(get_qr(qr_NEWENEMYTILES))
14169 {
14170 1043930 tile+=dummy_int[1]*40;
14171
14172
2/2
✓ Branch 0 taken 102730 times.
✓ Branch 1 taken 941200 times.
1043930 if(dir<8)
14173 {
14174 102730 flip=0;
14175
1/2
✓ Branch 0 taken 102730 times.
✗ Branch 1 not taken.
102730 tile+=4*zc_max(dir, 0); // dir is -1 if trapped
14176
14177
1/2
✓ Branch 0 taken 102730 times.
✗ Branch 1 not taken.
102730 if(dir>3) // Skip to the next row for diagonals
14178 tile+=4;
14179 102730 }
14180 else
14181 {
14182
8/9
✓ Branch 0 taken 96530 times.
✓ Branch 1 taken 134534 times.
✓ Branch 2 taken 113426 times.
✓ Branch 3 taken 124800 times.
✓ Branch 4 taken 101314 times.
✓ Branch 5 taken 99043 times.
✓ Branch 6 taken 131794 times.
✓ Branch 7 taken 139759 times.
✗ Branch 8 not taken.
941200 switch(dir-8) //directions get screwed up after 8. *shrug*
14183 {
14184 case up: //u
14185 96530 flip=0;
14186 96530 break;
14187
14188 case l_up: //d
14189 134534 flip=0;
14190 134534 tile+=4;
14191 134534 break;
14192
14193 case l_down: //l
14194 113426 flip=0;
14195 113426 tile+=8;
14196 113426 break;
14197
14198 case left: //r
14199 124800 flip=0;
14200 124800 tile+=12;
14201 124800 break;
14202
14203 case r_down: //ul
14204 101314 flip=0;
14205 101314 tile+=20;
14206 101314 break;
14207
14208 case down: //ur
14209 99043 flip=0;
14210 99043 tile+=24;
14211 99043 break;
14212
14213 case r_up: //dl
14214 131794 flip=0;
14215 131794 tile+=28;
14216 131794 break;
14217
14218 case right: //dr
14219 139759 flip=0;
14220 139759 tile+=32;
14221 139759 break;
14222 }
14223 }
14224
14225 1043930 tile+=f2;
14226 1043930 }
14227
14228
2/2
✓ Branch 0 taken 106267 times.
✓ Branch 1 taken 1049046 times.
1155313 if(clk>=0)
14229 1049046 enemy::draw(dest);
14230 1155313 }
14231
14232 420 eLanmola::eLanmola(zfix X,zfix Y,int32_t Id,int32_t Clk) : eBaseLanmola(X,Y,Id,Clk)
14233 420 {
14234
1/2
✓ Branch 0 taken 420 times.
✗ Branch 1 not taken.
420 if( !(editorflags & ENEMY_FLAG5) )
14235 {
14236
1/2
✓ Branch 0 taken 420 times.
✗ Branch 1 not taken.
420 x=64;
14237
1/2
✓ Branch 0 taken 420 times.
✗ Branch 1 not taken.
420 y=80;
14238 420 }
14239 //else { x = X; y = Y; }
14240 //byte legaldirs = 0;
14241 420 int32_t incr = 16;
14242 //int32_t possiiblepos = 0;
14243 //int32_t positions[8] = {0};
14244
14245 //Don't spawn in pits.
14246
5/8
✓ Branch 0 taken 420 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 420 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 420 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 315 times.
✓ Branch 7 taken 105 times.
420 if ( m_walkflag_simple(x, y) )
14247 {
14248
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 139 times.
139 for ( ; incr < 240; incr += 16 )
14249 {
14250 //move if we spawn over a pit
14251 //check each direction
14252
7/12
✓ Branch 0 taken 139 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 139 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 139 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 139 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 139 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 4 times.
✓ Branch 11 taken 135 times.
139 if ( !m_walkflag_simple(x-incr, y) ) //legaldirs |= 0x1; //left
14253 {
14254
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 x-=incr; break;
14255 }
14256
7/12
✓ Branch 0 taken 135 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 135 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 135 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 135 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 135 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 39 times.
✓ Branch 11 taken 96 times.
135 else if ( !m_walkflag_simple(x+incr, y) ) //legaldirs |= 0x2; //right
14257 {
14258
1/2
✓ Branch 0 taken 39 times.
✗ Branch 1 not taken.
39 x+=incr; break;
14259 }
14260
9/16
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 96 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 96 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 96 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 96 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 96 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 96 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 32 times.
✓ Branch 15 taken 64 times.
96 else if ( !m_walkflag_simple(x-incr, y-incr) ) //legaldirs |= 0x4; //left-up
14261 {
14262
2/4
✓ Branch 0 taken 32 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 32 times.
✗ Branch 3 not taken.
32 x-=incr; y-=incr; break;
14263 }
14264
9/16
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 64 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 64 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 64 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 64 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 64 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 64 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 4 times.
✓ Branch 15 taken 60 times.
64 else if ( !m_walkflag_simple(x+incr, y-incr) ) //legaldirs |= 0x8; //right-up
14265 {
14266
2/4
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
4 x+=incr; y-=incr; break;
14267 }
14268
6/12
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 60 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 60 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 60 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 60 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 60 times.
60 else if ( !m_walkflag_simple(x, y-incr) ) // legaldirs |= 0x10; //up
14269 {
14270 y -= incr; break;
14271 }
14272
6/12
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 60 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 60 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 60 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 60 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 60 times.
60 else if ( !m_walkflag_simple(x, y+incr) ) //legaldirs |= 0x20; //down
14273 {
14274 y+=incr; break;
14275 }
14276
9/16
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 60 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 60 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 60 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 60 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 60 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 60 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 26 times.
✓ Branch 15 taken 34 times.
60 else if ( !m_walkflag_simple(x-incr, y+incr) ) //legaldirs |= 0x40; //left-down
14277 {
14278
2/4
✓ Branch 0 taken 26 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 26 times.
✗ Branch 3 not taken.
26 x-=incr; y+=incr; break;
14279 }
14280
8/16
✓ Branch 0 taken 34 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 34 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 34 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 34 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 34 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 34 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 34 times.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✓ Branch 15 taken 34 times.
34 else if ( !m_walkflag_simple(x+incr, y+incr) ) //legaldirs |= 0x80; //right-down
14281 {
14282 x+=incr; y+=incr; break;
14283 }
14284 34 else continue;
14285
14286 }
14287
14288 105 }
14289
14290 420 dir=up;
14291 420 superman=1;
14292 420 fading=fade_invisible;
14293 420 hxofs=1000;
14294 420 segcnt=clk;
14295 420 clk=0;
14296 //set up move history
14297
2/2
✓ Branch 0 taken 420 times.
✓ Branch 1 taken 3060 times.
3480 for(int32_t i=0; i <= (1<<dmisc2); i++)
14298
3/6
✓ Branch 0 taken 3060 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3060 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3060 times.
✗ Branch 5 not taken.
3060 prevState.push_back(std::pair<std::pair<zfix, zfix>, int32_t>(std::pair<zfix,zfix>(x,y), dir));
14299 420 }
14300
14301 236907 bool eLanmola::animate(int32_t index)
14302 {
14303
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 236907 times.
236907 if(switch_hooked) return enemy::animate(index);
14304
2/2
✓ Branch 0 taken 196711 times.
✓ Branch 1 taken 40196 times.
236907 if(clk==0)
14305 {
14306 40196 removearmos(x,y,ffcactivated);
14307 40196 }
14308
14309
2/2
✓ Branch 0 taken 3591 times.
✓ Branch 1 taken 233316 times.
236907 if(clk2)
14310 {
14311
2/2
✓ Branch 0 taken 3402 times.
✓ Branch 1 taken 189 times.
3591 if(--clk2 == 0)
14312 {
14313
2/2
✓ Branch 0 taken 86 times.
✓ Branch 1 taken 103 times.
189 if(!dmisc3) //This checks if "segments drop items" isn't true, because if they don't drop items, then only killing the whole thing drops an item.
14314 86 leave_item();
14315
14316 189 stop_bgsfx(index);
14317 189 return true;
14318 }
14319
14320 3402 return false;
14321 }
14322
14323
14324 //this animation style plays ALL KINDS of havoc on the Lanmola segments, since it causes
14325 //the direction AND x,y position of the lanmola to vary in uncertain ways.
14326 //I've added a complete movement history to this enemy to compensate -DD
14327 233316 constant_walk(rate,homing,spw_none);
14328 233316 prevState.pop_front();
14329 233316 prevState.push_front(std::pair<std::pair<zfix, zfix>, int32_t>(std::pair<zfix, zfix>(x,y), dir));
14330
14331 // This could cause a crash with Moldorms. I didn't see the same problem
14332 // with Lanmolas, but it looks like it ought to be possible, so here's
14333 // the same solution. - Saf
14334
1/2
✓ Branch 0 taken 233316 times.
✗ Branch 1 not taken.
233316 if(index+segcnt>=guys.Count())
14335 segcnt=guys.Count()-index-1;
14336
14337
2/2
✓ Branch 0 taken 233316 times.
✓ Branch 1 taken 966396 times.
1199712 for(int32_t i=index+1; i<index+segcnt+1; i++)
14338 {
14339 966396 enemy* segment=((enemy*)guys.spr(i));
14340
14341 // More validation in case segcnt is wrong
14342
1/2
✓ Branch 0 taken 966396 times.
✗ Branch 1 not taken.
966396 if((segment->id&0xFFF)!=(id&0xFFF))
14343 {
14344 segcnt=i-index-1;
14345 break;
14346 }
14347
14348 966396 segment->o_tile=o_tile;
14349 966396 segment->parent_script_UID = this->script_UID;
14350
4/4
✓ Branch 0 taken 233316 times.
✓ Branch 1 taken 733080 times.
✓ Branch 2 taken 37616 times.
✓ Branch 3 taken 195700 times.
966396 if((i==index+segcnt)&&(i!=index+1))
14351 {
14352 195700 segment->dummy_int[1]=1; //tail
14353 195700 }
14354 else
14355 {
14356 770696 segment->dummy_int[1]=0;
14357 }
14358
14359
2/2
✓ Branch 0 taken 965227 times.
✓ Branch 1 taken 1169 times.
966396 if(segment->hp <= 0)
14360 {
14361
2/2
✓ Branch 0 taken 1169 times.
✓ Branch 1 taken 1961 times.
3130 for(int32_t j=i; j<index+segcnt; j++)
14362 {
14363 // Triple-check
14364
1/2
✓ Branch 0 taken 1961 times.
✗ Branch 1 not taken.
1961 if((((enemy*)guys.spr(j+1))->id&0xFFF)!=(id&0xFFF))
14365 {
14366 segcnt=j-index+1; // Add 1 because of --segcnt below
14367 break;
14368 }
14369 1961 zc_swap(((enemy*)guys.spr(j))->hp,((enemy*)guys.spr(j+1))->hp);
14370 1961 zc_swap(((enemy*)guys.spr(j))->hclk,((enemy*)guys.spr(j+1))->hclk);
14371 1961 }
14372
14373 1169 ((enemy*)guys.spr(i))->hclk=33;
14374 1169 --segcnt;
14375 1169 --i; // Recheck the same index in case multiple segments died at once
14376 1169 }
14377 966396 }
14378
14379
2/2
✓ Branch 0 taken 233127 times.
✓ Branch 1 taken 189 times.
233316 if(segcnt==0)
14380 {
14381 189 clk2=19;
14382 189 x=guys.spr(index+1)->x;
14383 189 y=guys.spr(index+1)->y;
14384 189 setmapflag(mTMPNORET);
14385 189 }
14386
14387 //this enemy is invincible.. BUT scripts don't know that, and can "kill" it by setting the hp negative.
14388 //which is... disastrous.
14389 233316 hp = 1;
14390 233316 return enemy::animate(index);
14391 236907 }
14392
14393 2267 esLanmola::esLanmola(zfix X,zfix Y,int32_t Id,int32_t Clk) : eBaseLanmola(X,Y,Id,Clk)
14394 2267 {
14395
1/2
✓ Branch 0 taken 2267 times.
✗ Branch 1 not taken.
2267 if( !(editorflags & ENEMY_FLAG5) )
14396 {
14397
1/2
✓ Branch 0 taken 2267 times.
✗ Branch 1 not taken.
2267 x=64;
14398
1/2
✓ Branch 0 taken 2267 times.
✗ Branch 1 not taken.
2267 y=80;
14399 2267 }
14400 2267 int32_t incr = 16;
14401 //Don't spawn in pits.
14402
5/8
✓ Branch 0 taken 2267 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2267 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2267 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1742 times.
✓ Branch 7 taken 525 times.
2267 if ( m_walkflag_simple(x, y) )
14403 {
14404
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 695 times.
695 for ( ; incr < 240; incr += 16 )
14405 {
14406 //move if we spawn over a pit
14407 //check each direction
14408
7/12
✓ Branch 0 taken 695 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 695 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 695 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 695 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 695 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 20 times.
✓ Branch 11 taken 675 times.
695 if ( !m_walkflag_simple(x-incr, y) ) //legaldirs |= 0x1; //left
14409 {
14410
1/2
✓ Branch 0 taken 20 times.
✗ Branch 1 not taken.
20 x-=incr; break;
14411 }
14412
7/12
✓ Branch 0 taken 675 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 675 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 675 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 675 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 675 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 195 times.
✓ Branch 11 taken 480 times.
675 else if ( !m_walkflag_simple(x+incr, y) ) //legaldirs |= 0x2; //right
14413 {
14414
1/2
✓ Branch 0 taken 195 times.
✗ Branch 1 not taken.
195 x+=incr; break;
14415 }
14416
9/16
✓ Branch 0 taken 480 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 480 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 480 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 480 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 480 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 480 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 480 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 160 times.
✓ Branch 15 taken 320 times.
480 else if ( !m_walkflag_simple(x-incr, y-incr) ) //legaldirs |= 0x4; //left-up
14417 {
14418
2/4
✓ Branch 0 taken 160 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 160 times.
✗ Branch 3 not taken.
160 x-=incr; y-=incr; break;
14419 }
14420
9/16
✓ Branch 0 taken 320 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 320 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 320 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 320 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 320 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 320 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 320 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 20 times.
✓ Branch 15 taken 300 times.
320 else if ( !m_walkflag_simple(x+incr, y-incr) ) //legaldirs |= 0x8; //right-up
14421 {
14422
2/4
✓ Branch 0 taken 20 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 20 times.
✗ Branch 3 not taken.
20 x+=incr; y-=incr; break;
14423 }
14424
6/12
✓ Branch 0 taken 300 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 300 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 300 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 300 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 300 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 300 times.
300 else if ( !m_walkflag_simple(x, y-incr) ) // legaldirs |= 0x10; //up
14425 {
14426 y -= incr; break;
14427 }
14428
6/12
✓ Branch 0 taken 300 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 300 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 300 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 300 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 300 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 300 times.
300 else if ( !m_walkflag_simple(x, y+incr) ) //legaldirs |= 0x20; //down
14429 {
14430 y+=incr; break;
14431 }
14432
9/16
✓ Branch 0 taken 300 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 300 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 300 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 300 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 300 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 300 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 300 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 130 times.
✓ Branch 15 taken 170 times.
300 else if ( !m_walkflag_simple(x-incr, y+incr) ) //legaldirs |= 0x40; //left-down
14433 {
14434
2/4
✓ Branch 0 taken 130 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 130 times.
✗ Branch 3 not taken.
130 x-=incr; y+=incr; break;
14435 }
14436
8/16
✓ Branch 0 taken 170 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 170 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 170 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 170 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 170 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 170 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 170 times.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✓ Branch 15 taken 170 times.
170 else if ( !m_walkflag_simple(x+incr, y+incr) ) //legaldirs |= 0x80; //right-down
14437 {
14438 x+=incr; y+=incr; break;
14439 }
14440 170 else continue;
14441
14442 }
14443
14444 525 }
14445
14446 2267 hxofs=1000;
14447 2267 hit_width=8;
14448 2267 mainguy=false;
14449 2267 count_enemy=(id<0x2000)?true:false;
14450
14451 //set up move history
14452
2/2
✓ Branch 0 taken 2267 times.
✓ Branch 1 taken 16763 times.
19030 for(int32_t i=0; i <= (1<<dmisc2); i++)
14453
3/6
✓ Branch 0 taken 16763 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 16763 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 16763 times.
✗ Branch 5 not taken.
16763 prevState.push_back(std::pair<std::pair<zfix, zfix>, int32_t>(std::pair<zfix,zfix>(x,y), dir));
14454
14455 2267 bgsfx = -1;
14456 2267 isCore = false;
14457
2/4
✓ Branch 0 taken 2267 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2267 times.
✗ Branch 3 not taken.
2267 flags&=~guy_never_return;
14458 2267 }
14459
14460 985563 bool esLanmola::animate(int32_t index)
14461 {
14462
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 985563 times.
985563 if(switch_hooked) return enemy::animate(index);
14463 // Shouldn't be possible, but who knows
14464
2/2
✓ Branch 0 taken 985545 times.
✓ Branch 1 taken 18 times.
985563 if(index==0)
14465 18 dying=true;
14466
14467
2/2
✓ Branch 0 taken 19167 times.
✓ Branch 1 taken 966396 times.
985563 if(dying)
14468 {
14469 19167 xofs=0;
14470
14471
2/2
✓ Branch 0 taken 9861 times.
✓ Branch 1 taken 9306 times.
19167 if(!dmisc3)
14472 9306 item_set=0;
14473
14474 19167 return Dead(index);
14475 }
14476
14477
2/2
✓ Branch 0 taken 35946 times.
✓ Branch 1 taken 930450 times.
966396 if(clk>=0)
14478 {
14479 930450 hxofs=4;
14480
14481
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 930450 times.
930450 if(!watch)
14482 {
14483 930450 std::pair<std::pair<zfix, zfix>, int32_t> newstate = ((eBaseLanmola*)guys.spr(index-1))->prevState.front();
14484 930450 prevState.pop_front();
14485 930450 prevState.push_back(newstate);
14486 930450 x = newstate.first.first;
14487 930450 y = newstate.first.second;
14488 930450 dir = newstate.second;
14489 930450 }
14490 930450 }
14491
14492 966396 return enemy::animate(index);
14493 985563 }
14494
14495 2655 int32_t esLanmola::takehit(weapon *w, weapon* realweap)
14496 {
14497
2/2
✓ Branch 0 taken 2065 times.
✓ Branch 1 taken 590 times.
2655 if(enemy::takehit(w,realweap))
14498 2065 return (w->id==wSBomb) ? 1 : 2; // force it to wait a frame before checking sword attacks again
14499
14500 590 return 0;
14501 2655 }
14502
14503 990931 void esLanmola::draw(BITMAP *dest)
14504 {
14505 990931 tile=o_tile;
14506 990931 int32_t fdiv = frate/4;
14507
1/2
✓ Branch 0 taken 990931 times.
✗ Branch 1 not taken.
990931 int32_t efrate = fdiv == 0 ? 0 : clk/fdiv;
14508
14509
2/2
✓ Branch 0 taken 628932 times.
✓ Branch 1 taken 361999 times.
990931 int32_t f2=get_qr(qr_NEWENEMYTILES)?
14510 990931 efrate:((clk>=(frate>>1))?1:0);
14511
14512
2/2
✓ Branch 0 taken 628932 times.
✓ Branch 1 taken 361999 times.
990931 if(get_qr(qr_NEWENEMYTILES))
14513 {
14514
2/2
✓ Branch 0 taken 147165 times.
✓ Branch 1 taken 481767 times.
628932 if(id>=0x2000)
14515 {
14516 481767 tile+=20;
14517
14518
2/2
✓ Branch 0 taken 353025 times.
✓ Branch 1 taken 128742 times.
481767 if(dummy_int[1]==1)
14519 {
14520 128742 tile+=20;
14521 128742 }
14522 481767 }
14523
14524
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 141419 times.
✓ Branch 2 taken 140994 times.
✓ Branch 3 taken 159500 times.
✓ Branch 4 taken 187019 times.
628932 switch(dir)
14525 {
14526 case up:
14527 141419 flip=0;
14528 141419 break;
14529
14530 case down:
14531 140994 flip=0;
14532 140994 tile+=4;
14533 140994 break;
14534
14535 case left:
14536 159500 flip=0;
14537 159500 tile+=8;
14538 159500 break;
14539
14540 case right:
14541 187019 flip=0;
14542 187019 tile+=12;
14543 187019 break;
14544 }
14545
14546 628932 tile+=f2;
14547 628932 }
14548 else
14549 {
14550
2/2
✓ Branch 0 taken 90543 times.
✓ Branch 1 taken 271456 times.
361999 if(id>=0x2000)
14551 {
14552 271456 tile+=1;
14553 271456 }
14554 }
14555
14556
2/2
✓ Branch 0 taken 37038 times.
✓ Branch 1 taken 953893 times.
990931 if(clk>=0)
14557 953893 enemy::draw(dest);
14558 990931 }
14559
14560 150 eManhandla::eManhandla(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,0)
14561 150 {
14562 //these are here to bypass compiler warnings about unused arguments
14563 150 Clk=Clk;
14564 150 superman=1;
14565
1/2
✓ Branch 0 taken 150 times.
✗ Branch 1 not taken.
150 dir=(zc_oldrand()&7)+8;
14566 150 armcnt=dmisc2?8:4;//((id==eMANHAN)?4:8);
14567
14568
2/2
✓ Branch 0 taken 692 times.
✓ Branch 1 taken 150 times.
842 for(int32_t i=0; i<armcnt; i++)
14569 692 arm[i]=i;
14570
14571 150 fading=fade_blue_poof;
14572 //nets+4680;
14573 150 adjusted=false;
14574
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 150 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
150 if (SIZEflags != 0) init_size_flags();;
14575 150 }
14576
14577 66494 bool eManhandla::animate(int32_t index)
14578 {
14579
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 66494 times.
66494 if(switch_hooked) return enemy::animate(index);
14580
2/2
✓ Branch 0 taken 1382 times.
✓ Branch 1 taken 65112 times.
66494 if(dying)
14581 1382 return Dead(index);
14582
14583
2/2
✓ Branch 0 taken 62641 times.
✓ Branch 1 taken 2471 times.
65112 if(clk==0)
14584 {
14585 2471 removearmos(x,y,ffcactivated);
14586 2471 }
14587
14588
14589 // check arm status, move dead ones to end of group
14590
2/2
✓ Branch 0 taken 193618 times.
✓ Branch 1 taken 65112 times.
258730 for(int32_t i=0; i<armcnt; i++)
14591 {
14592 193618 enemy* cur_arm = ((enemy*)guys.spr(index+i+1));
14593
3/4
✓ Branch 0 taken 193618 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 424 times.
✓ Branch 3 taken 193194 times.
193618 if(!cur_arm || cur_arm->dying)
14594 {
14595
2/2
✓ Branch 0 taken 552 times.
✓ Branch 1 taken 424 times.
976 for(int32_t j=i; j<armcnt-1; j++)
14596 {
14597 552 zc_swap(arm[j],arm[j+1]);
14598 552 guys.swap(index+j+1,index+j+2);
14599 552 }
14600
2/2
✓ Branch 0 taken 337 times.
✓ Branch 1 taken 87 times.
424 if((editorflags & ENEMY_FLAG6)) //They only did this in 2.10
14601 {
14602 87 leave_item();
14603 87 }
14604 424 --armcnt;
14605 424 --i;
14606 424 continue;
14607 }
14608
2/2
✓ Branch 0 taken 192502 times.
✓ Branch 1 taken 692 times.
193194 if(!adjusted)
14609 {
14610
2/2
✓ Branch 0 taken 508 times.
✓ Branch 1 taken 184 times.
692 if(!dmisc2)
14611 {
14612 508 cur_arm->o_tile=o_tile+40;
14613 508 cur_arm->parent_script_UID = this->script_UID;
14614 508 }
14615 else
14616 {
14617 184 cur_arm->o_tile=o_tile+160;
14618 184 cur_arm->parent_script_UID = this->script_UID;
14619 }
14620 692 }
14621 193194 }
14622
14623 65112 adjusted=true;
14624
14625 // move or die
14626
2/2
✓ Branch 0 taken 65029 times.
✓ Branch 1 taken 83 times.
65112 if(armcnt==0)
14627 83 hp=0;
14628 else
14629 {
14630 // Speed starts at 0.5, and increases by 0.5 for each head lost. Max speed is 4.5.
14631
2/2
✓ Branch 0 taken 53584 times.
✓ Branch 1 taken 11445 times.
65029 step = ((dmisc2 ? 8_zf : 4_zf) - armcnt) * 0.5 + (dstep / 100);
14632
1/2
✓ Branch 0 taken 65029 times.
✗ Branch 1 not taken.
65029 if (step > 4.5_zf) step = 4.5_zf;
14633 65029 int32_t dx1=0, dy1=-8, dx2=15, dy2=15;
14634
14635
2/2
✓ Branch 0 taken 53584 times.
✓ Branch 1 taken 11445 times.
65029 if(!dmisc2)
14636 {
14637
2/2
✓ Branch 0 taken 151019 times.
✓ Branch 1 taken 53584 times.
204603 for(int32_t i=0; i<armcnt; i++)
14638 {
14639
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 38579 times.
✓ Branch 2 taken 36328 times.
✓ Branch 3 taken 36250 times.
✓ Branch 4 taken 39862 times.
151019 switch(arm[i])
14640 {
14641 case 0:
14642 38579 dy1=-24;
14643 38579 break;
14644
14645 case 1:
14646 36328 dy2=31;
14647 36328 break;
14648
14649 case 2:
14650 36250 dx1=-16;
14651 36250 break;
14652
14653 case 3:
14654 39862 dx2=31;
14655 39862 break;
14656 }
14657 151019 }
14658 53584 }
14659 else
14660 {
14661 11445 dx1=-8, dy1=-16, dx2=23, dy2=23;
14662
14663
2/2
✓ Branch 0 taken 42175 times.
✓ Branch 1 taken 11445 times.
53620 for(int32_t i=0; i<armcnt; i++)
14664 {
14665
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 12012 times.
✓ Branch 2 taken 7730 times.
✓ Branch 3 taken 9837 times.
✓ Branch 4 taken 12596 times.
42175 switch(arm[i]&3)
14666 {
14667 case 0:
14668 12012 dy1=-32;
14669 12012 break;
14670
14671 case 1:
14672 7730 dy2=39;
14673 7730 break;
14674
14675 case 2:
14676 9837 dx1=-24;
14677 9837 break;
14678
14679 case 3:
14680 12596 dx2=39;
14681 12596 break;
14682 }
14683 42175 }
14684 }
14685
14686 65029 variable_walk_8(rate,homing,hrate,spw_floater,dx1,dy1,dx2,dy2);
14687
14688
2/2
✓ Branch 0 taken 193194 times.
✓ Branch 1 taken 65029 times.
258223 for(int32_t i=0; i<armcnt; i++)
14689 {
14690 193194 zfix dx=(zfix)0,dy=(zfix)0;
14691
14692
2/2
✓ Branch 0 taken 151019 times.
✓ Branch 1 taken 42175 times.
193194 if(!dmisc2)
14693 {
14694
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 38579 times.
✓ Branch 2 taken 36328 times.
✓ Branch 3 taken 36250 times.
✓ Branch 4 taken 39862 times.
151019 switch(arm[i])
14695 {
14696 case 0:
14697 38579 dy=-16;
14698 38579 break;
14699
14700 case 1:
14701 36328 dy=16;
14702 36328 break;
14703
14704 case 2:
14705 36250 dx=-16;
14706 36250 break;
14707
14708 case 3:
14709 39862 dx=16;
14710 39862 break;
14711 }
14712 151019 }
14713 else
14714 {
14715
8/9
✗ Branch 0 not taken.
✓ Branch 1 taken 5447 times.
✓ Branch 2 taken 3986 times.
✓ Branch 3 taken 4163 times.
✓ Branch 4 taken 6774 times.
✓ Branch 5 taken 6565 times.
✓ Branch 6 taken 3744 times.
✓ Branch 7 taken 5674 times.
✓ Branch 8 taken 5822 times.
42175 switch(arm[i])
14716 {
14717 case 0:
14718 5447 dy=-24;
14719 5447 dx=-8;
14720 5447 break;
14721
14722 case 1:
14723 3986 dy=24;
14724 3986 dx=8;
14725 3986 break;
14726
14727 case 2:
14728 4163 dx=-24;
14729 4163 dy=8;
14730 4163 break;
14731
14732 case 3:
14733 6774 dx=24;
14734 6774 dy=-8;
14735 6774 break;
14736
14737 case 4:
14738 6565 dy=-24;
14739 6565 dx=8;
14740 6565 break;
14741
14742 case 5:
14743 3744 dy=24;
14744 3744 dx=-8;
14745 3744 break;
14746
14747 case 6:
14748 5674 dx=-24;
14749 5674 dy=-8;
14750 5674 break;
14751
14752 case 7:
14753 5822 dx=24;
14754 5822 dy=8;
14755 5822 break;
14756 }
14757 }
14758
14759 193194 guys.spr(index+i+1)->x = x+dx;
14760 193194 guys.spr(index+i+1)->y = y+dy;
14761 193194 }
14762 }
14763
14764 65112 return enemy::animate(index);
14765 66494 }
14766
14767
14768 1751 int32_t eManhandla::takehit(weapon *w, weapon* realweap)
14769 {
14770 1751 int32_t wpnId = w->id;
14771
14772
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1751 times.
1751 if(dying)
14773 return 0;
14774
14775
3/4
✓ Branch 0 taken 923 times.
✓ Branch 1 taken 786 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 42 times.
1751 switch(wpnId)
14776 {
14777 case wBomb:
14778 case wSBomb:
14779 case wSword:
14780 case wHammer:
14781 case wWand:
14782
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 786 times.
786 if (get_qr(qr_MANHANDLA_BLOCK_SFX)) sfx(WAV_EHIT,pan(int32_t(x)));
14783
14784 case wLitBomb:
14785 case wLitSBomb:
14786 case wBait:
14787 case wWhistle:
14788 case wFire:
14789 case wWind:
14790 case wSSparkle:
14791 case wFSparkle:
14792 case wPhantom:
14793 1709 return 0;
14794
14795 case wHookshot:
14796 case wBrang:
14797 sfx(WAV_CHINK,pan(int32_t(x)));
14798 break;
14799
14800 default:
14801
1/2
✓ Branch 0 taken 42 times.
✗ Branch 1 not taken.
42 if (get_qr(qr_MANHANDLA_BLOCK_SFX)) sfx(WAV_EHIT,pan(int32_t(x)));
14802 else sfx(WAV_CHINK,pan(int32_t(x)));
14803
14804 42 }
14805
14806 42 return 1;
14807 1751 }
14808
14809 66490 void eManhandla::draw(BITMAP *dest)
14810 {
14811 66490 tile=o_tile;
14812 66490 int32_t fdiv = frate/4;
14813
1/2
✓ Branch 0 taken 66490 times.
✗ Branch 1 not taken.
66490 int32_t efrate = fdiv == 0 ? 0 : clk/fdiv;
14814
14815
2/2
✓ Branch 0 taken 48802 times.
✓ Branch 1 taken 17688 times.
66490 int32_t f2=get_qr(qr_NEWENEMYTILES)?
14816 66490 efrate:((clk>=(frate>>1))?1:0);
14817
14818
2/2
✓ Branch 0 taken 48802 times.
✓ Branch 1 taken 17688 times.
66490 if(get_qr(qr_NEWENEMYTILES))
14819 {
14820
2/2
✓ Branch 0 taken 11308 times.
✓ Branch 1 taken 37494 times.
48802 if(!dmisc2)
14821 {
14822
8/9
✓ Branch 0 taken 4771 times.
✓ Branch 1 taken 4640 times.
✓ Branch 2 taken 4995 times.
✓ Branch 3 taken 5574 times.
✓ Branch 4 taken 3793 times.
✓ Branch 5 taken 3930 times.
✓ Branch 6 taken 3908 times.
✓ Branch 7 taken 5883 times.
✗ Branch 8 not taken.
37494 switch(dir-8) //directions get screwed up after 8. *shrug*
14823 {
14824 case up: //u
14825 4771 flip=0;
14826 4771 break;
14827
14828 case l_up: //d
14829 4640 flip=0;
14830 4640 tile+=4;
14831 4640 break;
14832
14833 case l_down: //l
14834 4995 flip=0;
14835 4995 tile+=8;
14836 4995 break;
14837
14838 case left: //r
14839 5574 flip=0;
14840 5574 tile+=12;
14841 5574 break;
14842
14843 case r_down: //ul
14844 3793 flip=0;
14845 3793 tile+=20;
14846 3793 break;
14847
14848 case down: //ur
14849 3930 flip=0;
14850 3930 tile+=24;
14851 3930 break;
14852
14853 case r_up: //dl
14854 3908 flip=0;
14855 3908 tile+=28;
14856 3908 break;
14857
14858 case right: //dr
14859 5883 flip=0;
14860 5883 tile+=32;
14861 5883 break;
14862 }
14863
14864 37494 tile+=f2;
14865 37494 enemy::draw(dest);
14866 37494 } //manhandla 2, big body
14867 else
14868 {
14869
14870
8/9
✗ Branch 0 not taken.
✓ Branch 1 taken 1277 times.
✓ Branch 2 taken 1360 times.
✓ Branch 3 taken 2242 times.
✓ Branch 4 taken 1789 times.
✓ Branch 5 taken 1345 times.
✓ Branch 6 taken 805 times.
✓ Branch 7 taken 948 times.
✓ Branch 8 taken 1542 times.
11308 switch(dir-8) //directions get screwed up after 8. *shrug*
14871 {
14872 case up: //u
14873 1277 flip=0;
14874 1277 break;
14875
14876 case l_up: //d
14877 1360 flip=0;
14878 1360 tile+=8;
14879 1360 break;
14880
14881 case l_down: //l
14882 2242 flip=0;
14883 2242 tile+=40;
14884 2242 break;
14885
14886 case left: //r
14887 1789 flip=0;
14888 1789 tile+=48;
14889 1789 break;
14890
14891 case r_down: //ul
14892 1345 flip=0;
14893 1345 tile+=80;
14894 1345 break;
14895
14896 case down: //ur
14897 805 flip=0;
14898 805 tile+=88;
14899 805 break;
14900
14901 case r_up: //dl
14902 948 flip=0;
14903 948 tile+=120;
14904 948 break;
14905
14906 case right: //dr
14907 1542 flip=0;
14908 1542 tile+=128;
14909 1542 break;
14910 }
14911
14912 11308 tile+=(f2*2);
14913 11308 xofs-=8;
14914 11308 yofs-=8;
14915 11308 drawblock(dest,15);
14916 11308 xofs+=8;
14917 11308 yofs+=8;
14918 }
14919 48802 }
14920 else
14921 {
14922
2/2
✓ Branch 0 taken 515 times.
✓ Branch 1 taken 17173 times.
17688 if(!dmisc2)
14923 {
14924 17173 enemy::draw(dest);
14925 17173 }
14926 else
14927 {
14928 515 xofs-=8;
14929 515 yofs-=8;
14930 515 enemy::draw(dest);
14931 515 xofs+=16;
14932 515 enemy::draw(dest);
14933 515 yofs+=16;
14934 515 enemy::draw(dest);
14935 515 xofs-=16;
14936 515 enemy::draw(dest);
14937 515 xofs+=8;
14938 515 yofs-=8;
14939 }
14940 }
14941 66490 }
14942
14943 692 esManhandla::esManhandla(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
14944 692 {
14945 692 id=misc=clk;
14946 692 dir = clk & 3;
14947 692 clk=0;
14948 692 mainguy=count_enemy=false;
14949 692 dummy_bool[0]=false;
14950 692 item_set=0;
14951 692 bgsfx=-1;
14952 692 deadsfx = WAV_EDEAD;
14953
2/4
✓ Branch 0 taken 692 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 692 times.
✗ Branch 3 not taken.
692 flags &= (~guy_never_return);
14954 692 isCore = false;
14955
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 692 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
692 if (SIZEflags != 0) init_size_flags();;
14956 692 }
14957
14958 200202 bool esManhandla::animate(int32_t index)
14959 {
14960
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 200202 times.
200202 if(switch_hooked) return enemy::animate(index);
14961
2/2
✓ Branch 0 taken 7008 times.
✓ Branch 1 taken 193194 times.
200202 if(dying)
14962 7008 return Dead(index);
14963
14964
2/2
✓ Branch 0 taken 12404 times.
✓ Branch 1 taken 180790 times.
193194 if(clk==0)
14965 {
14966 12404 removearmos(x,y,ffcactivated);
14967 12404 }
14968
14969
2/2
✓ Branch 0 taken 165298 times.
✓ Branch 1 taken 27896 times.
193194 if(--clk2<=0)
14970 {
14971 27896 clk2=unsigned(zc_oldrand())%5+5;
14972 27896 clk3^=1;
14973 27896 }
14974
14975
2/2
✓ Branch 0 taken 1491 times.
✓ Branch 1 taken 191703 times.
193194 if(!(zc_oldrand()&127))
14976 {
14977 1491 addEwpn(x,y,z,wpn,3,wdp,dir,getUID(), 0, fakez);
14978 1491 sfx(wpnsfx(wpn),pan(int32_t(x)));
14979 1491 }
14980
14981 193194 return enemy::animate(index);
14982 200202 }
14983
14984 200186 void esManhandla::draw(BITMAP *dest)
14985 {
14986 200186 tile=o_tile;
14987 200186 int32_t fdiv = frate/4;
14988
1/2
✓ Branch 0 taken 200186 times.
✗ Branch 1 not taken.
200186 int32_t efrate = fdiv == 0 ? 0 : clk/fdiv;
14989
2/2
✓ Branch 0 taken 158716 times.
✓ Branch 1 taken 41470 times.
200186 int32_t f2=get_qr(qr_NEWENEMYTILES)?
14990 200186 efrate:((clk>=(frate>>1))?1:0);
14991
14992
2/2
✓ Branch 0 taken 158716 times.
✓ Branch 1 taken 41470 times.
200186 if(get_qr(qr_NEWENEMYTILES))
14993 {
14994
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 39945 times.
✓ Branch 2 taken 36845 times.
✓ Branch 3 taken 39966 times.
✓ Branch 4 taken 41960 times.
158716 switch(misc&3)
14995 {
14996 case up:
14997 39945 break;
14998
14999 case down:
15000 36845 tile+=4;
15001 36845 break;
15002
15003 case left:
15004 39966 tile+=8;
15005 39966 break;
15006
15007 case right:
15008 41960 tile+=12;
15009 41960 break;
15010 }
15011
15012 158716 tile+=f2;
15013 158716 }
15014 else
15015 {
15016
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 12394 times.
✓ Branch 2 taken 7883 times.
✓ Branch 3 taken 8961 times.
✓ Branch 4 taken 12232 times.
41470 switch(misc&3)
15017 {
15018 case down:
15019 8961 flip=2;
15020
15021 [[fallthrough]];
15022 case up:
15023 21355 tile=(clk3)?188:189;
15024 21355 break;
15025
15026 case right:
15027 12232 flip=1;
15028 [[fallthrough]];
15029
15030 case left:
15031 20115 tile=(clk3)?186:187;
15032 20115 break;
15033 }
15034 }
15035
15036 200186 enemy::draw(dest);
15037 200186 }
15038
15039 168 eGleeok::eGleeok(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk) //enemy((zfix)120,(zfix)48,Id,Clk)
15040 168 {
15041
1/2
✓ Branch 0 taken 168 times.
✗ Branch 1 not taken.
168 if ( !(editorflags & ENEMY_FLAG5) )
15042 {
15043
1/2
✓ Branch 0 taken 168 times.
✗ Branch 1 not taken.
168 x = 120;
15044
1/2
✓ Branch 0 taken 168 times.
✗ Branch 1 not taken.
168 y = 48;
15045 168 }
15046 else
15047 {
15048 if ( !(editorflags & ENEMY_FLAG6) )
15049 {
15050 x = X; y = Y;
15051 }
15052 else
15053 {
15054 x = X+8; y = Y;
15055 }
15056 }
15057 168 hzsz = 32; // can't be jumped.
15058 168 flameclk=0;
15059 168 misc=clk; // total head count
15060 168 clk3=clk; // live head count
15061 168 clk=0;
15062 168 clk2=60; // fire ball clock
15063 // hp=(guysbuf[eGLEEOK2+(misc-2)].misc2)*(misc-1)*game->get_hero_dmgmult()+guysbuf[eGLEEOK2+(misc-2)].hp;
15064
1/2
✓ Branch 0 taken 168 times.
✗ Branch 1 not taken.
168 hp=(guysbuf[id&0xFFF].attributes[1])*(misc-1)*game->get_hero_dmgmult()+guysbuf[id&0xFFF].hp;
15065 168 dir = down;
15066 168 hxofs=4;
15067 168 hit_width=8;
15068 // frate=17*4;
15069 168 fading=fade_blue_poof;
15070 //nets+5420;
15071
2/2
✓ Branch 0 taken 133 times.
✓ Branch 1 taken 35 times.
168 if(get_qr(qr_NEWENEMYTILES))
15072 {
15073 /*
15074 necktile=o_tile+8;
15075 if (dmisc3)
15076 {
15077 necktile+=8;
15078 }
15079 */
15080 133 necktile=o_tile+dmisc6;
15081 133 }
15082 else
15083 {
15084 35 necktile=s_tile;
15085 }
15086 168 }
15087
15088 155290 bool eGleeok::animate(int32_t index)
15089 {
15090
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 155290 times.
155290 if(switch_hooked) return enemy::animate(index);
15091
2/2
✓ Branch 0 taken 2199 times.
✓ Branch 1 taken 153091 times.
155290 if(dying)
15092 2199 return Dead(index);
15093
15094
2/2
✓ Branch 0 taken 152407 times.
✓ Branch 1 taken 684 times.
153091 if(clk==0)
15095 {
15096 684 removearmos(x,y,ffcactivated);
15097 684 }
15098
15099 // Check if a head was killed somehow...
15100
2/2
✓ Branch 0 taken 101719 times.
✓ Branch 1 taken 51372 times.
153091 if(index+1+clk3>=guys.Count())
15101 51372 clk3=guys.Count()-index-1;
15102
2/2
✓ Branch 0 taken 66050 times.
✓ Branch 1 taken 87041 times.
153091 if(index+1+misc>=guys.Count())
15103 87041 misc=guys.Count()-index-1;
15104
15105 //fix for the "kill all enemies" item
15106
2/2
✓ Branch 0 taken 153085 times.
✓ Branch 1 taken 6 times.
153091 if(hp==-1000)
15107 {
15108
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 12 times.
18 for(int32_t i=0; i<clk3; ++i)
15109 {
15110 // I haven't seen this fail, but it seems like it ought to be
15111 // possible, so I'm checking for it. - Saf
15112
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if((((enemy*)guys.spr(index+i+1))->id&0xFFF)!=(id&0xFFF))
15113 break;
15114 12 ((enemy*)guys.spr(index+i+1))->hp=1; // re-animate each head,
15115 12 ((enemy*)guys.spr(index+i+1))->misc = -1; // disconnect it,
15116 12 ((enemy*)guys.spr(index+i+1))->animate(index+i+1); // let it animate one frame,
15117 12 ((enemy*)guys.spr(index+i+1))->hp=-1000; // and kill it for good
15118 12 }
15119
15120 6 clk3=0;
15121
15122
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 12 times.
18 for(int32_t i=0; i<misc; i++)
15123 {
15124
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if((((enemy*)guys.spr(index+i+1))->id&0xFFF)!=(id&0xFFF))
15125 break;
15126 12 ((enemy*)guys.spr(index+i+1))->misc = -2; // give the signal to disappear
15127 12 }
15128 6 }
15129
15130
2/2
✓ Branch 0 taken 403171 times.
✓ Branch 1 taken 153091 times.
556262 for(int32_t i=0; i<clk3; i++)
15131 {
15132 403171 enemy *head = ((enemy*)guys.spr(index+i+1));
15133 403171 head->dummy_int[1]=necktile;
15134 403171 head->parent_script_UID = this->script_UID;
15135
15136
2/2
✓ Branch 0 taken 320127 times.
✓ Branch 1 taken 83044 times.
403171 if(get_qr(qr_NEWENEMYTILES))
15137 {
15138 320127 head->dummy_int[2]=o_tile+dmisc8; //connected head tile
15139 320127 head->dummy_int[3]=o_tile+dmisc9; //flying head tile
15140 320127 }
15141 else
15142 {
15143 83044 head->dummy_int[2]=necktile+1; //connected head tile
15144 83044 head->dummy_int[3]=necktile+2; //flying head tile
15145 }
15146
15147 403171 head->dmisc5=dmisc5; //neck segments
15148
15149 /*
15150 if (dmisc3)
15151 {
15152 head->dummy_bool[0]=true;
15153 }
15154 */
15155
2/2
✓ Branch 0 taken 397516 times.
✓ Branch 1 taken 5655 times.
403171 if(head->hclk)
15156 {
15157
2/2
✓ Branch 0 taken 4427 times.
✓ Branch 1 taken 1228 times.
5655 if(hclk==0)
15158 {
15159 1228 hp -= 1000 - head->hp;
15160 1228 hclk = 33;
15161
15162
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1228 times.
1228 if(hitsfx>0) sfx(hitsfx,pan(int32_t(head->x)));
15163
15164 1228 sfx(WAV_EHIT,pan(int32_t(head->x)));
15165 1228 }
15166
15167 5655 head->hclk = 0;
15168 5655 }
15169
15170 // Must be set in case of naughty ZScripts
15171 403171 head->hp = 1000;
15172 403171 }
15173
15174
2/2
✓ Branch 0 taken 152676 times.
✓ Branch 1 taken 415 times.
153091 if(hp<=(guysbuf[id&0xFFF].attributes[1]) * (clk3 - 1) * game->get_hero_dmgmult())
15175 {
15176 415 ((enemy*)guys.spr(index+clk3))->misc = -1; // give signal to fly off
15177 415 hp=(guysbuf[id&0xFFF].attributes[1])*(--clk3)*game->get_hero_dmgmult();
15178 415 }
15179
15180
2/2
✓ Branch 0 taken 57409 times.
✓ Branch 1 taken 95682 times.
153091 if(!dmisc3)
15181 {
15182
4/4
✓ Branch 0 taken 5291 times.
✓ Branch 1 taken 90391 times.
✓ Branch 2 taken 1287 times.
✓ Branch 3 taken 4004 times.
95682 if(++clk2>72 && !(zc_oldrand()&3))
15183 {
15184 1287 int32_t i=zc_oldrand()%misc;
15185 1287 enemy *head = ((enemy*)guys.spr(index+i+1));
15186 1287 addEwpn(head->x,head->y,head->z,wpn,3,wdp,dir,getUID(), 0, head->fakez);
15187 1287 sfx(wpnsfx(wpn),pan(int32_t(x)));
15188 1287 clk2=0;
15189 1287 }
15190 95682 }
15191 else
15192 {
15193
4/4
✓ Branch 0 taken 2357 times.
✓ Branch 1 taken 55052 times.
✓ Branch 2 taken 1800 times.
✓ Branch 3 taken 557 times.
57409 if(++clk2>100 && !(zc_oldrand()&3))
15194 {
15195 557 enemy *head = ((enemy*)guys.spr(zc_oldrand()%misc+index+1));
15196 557 head->timer=zc_oldrand()%50+50;
15197 557 clk2=0;
15198 557 }
15199 }
15200
15201
3/4
✓ Branch 0 taken 127 times.
✓ Branch 1 taken 152964 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 127 times.
153091 if((hp<=0 && !immortal))
15202 {
15203
2/2
✓ Branch 0 taken 390 times.
✓ Branch 1 taken 127 times.
517 for(int32_t i=0; i<misc; i++)
15204 390 ((enemy*)guys.spr(index+i+1))->misc = -2; // give the signal to disappear
15205
15206
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 124 times.
127 if(flags&guy_never_return) never_return(index);
15207 127 }
15208
15209 153091 return enemy::animate(index);
15210 155290 }
15211
15212 1239 int32_t eGleeok::takehit(weapon*,weapon*)
15213 {
15214 1239 return 0;
15215 }
15216
15217 156918 void eGleeok::draw(BITMAP *dest)
15218 {
15219 156918 tile=o_tile;
15220
15221
2/2
✓ Branch 0 taken 2199 times.
✓ Branch 1 taken 154719 times.
156918 if(dying)
15222 {
15223 2199 enemy::draw(dest);
15224 2199 return;
15225 }
15226
15227 154719 int32_t f=clk/17;
15228
15229
2/2
✓ Branch 0 taken 120524 times.
✓ Branch 1 taken 34195 times.
154719 if(get_qr(qr_NEWENEMYTILES))
15230 {
15231 // body
15232 120524 xofs=-8;
15233 120524 yofs=32;
15234
15235
4/4
✓ Branch 0 taken 92588 times.
✓ Branch 1 taken 9155 times.
✓ Branch 2 taken 10095 times.
✓ Branch 3 taken 8686 times.
120524 switch(f)
15236
15237 {
15238 case 0:
15239 9155 tile+=0;
15240 9155 break;
15241
15242 case 1:
15243 10095 tile+=2;
15244 10095 break;
15245
15246 case 2:
15247 8686 tile+=4;
15248 8686 break;
15249
15250 default:
15251 92588 tile+=6;
15252 92588 break;
15253 }
15254 120524 }
15255 else
15256 {
15257 // body
15258 34195 xofs=-8;
15259 34195 yofs=32;
15260
15261
3/3
✓ Branch 0 taken 29222 times.
✓ Branch 1 taken 2514 times.
✓ Branch 2 taken 2459 times.
34195 switch(f)
15262 {
15263 case 0:
15264 2514 tile+=0;
15265 2514 break;
15266
15267 case 2:
15268 2459 tile+=4;
15269 2459 break;
15270
15271 default:
15272 29222 tile+=2;
15273 29222 break;
15274 }
15275 }
15276
15277 154719 enemy::drawblock(dest,15);
15278 156918 }
15279
15280 156918 void eGleeok::draw2(BITMAP *dest)
15281 {
15282 // the neck stub
15283 156918 tile=necktile;
15284 156918 xofs=0;
15285
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 156918 times.
156918 yofs=(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
15286
15287
2/2
✓ Branch 0 taken 34737 times.
✓ Branch 1 taken 122181 times.
156918 if(get_qr(qr_NEWENEMYTILES))
15288 {
15289 122181 tile+=((clk&24)>>3);
15290 122181 }
15291
15292
3/4
✓ Branch 0 taken 154719 times.
✓ Branch 1 taken 2199 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 154719 times.
156918 if(hp > 0 && !dont_draw())
15293 {
15294
4/4
✓ Branch 0 taken 4731 times.
✓ Branch 1 taken 149988 times.
✓ Branch 2 taken 737 times.
✓ Branch 3 taken 3994 times.
154719 if((tmpscr->flags3&fINVISROOM)&& !(current_item(itype_amulet)))
15295 737 sprite::drawcloaked(dest);
15296 else
15297 153982 sprite::draw(dest);
15298 154719 }
15299 156918 }
15300
15301
3/6
✓ Branch 0 taken 533 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 533 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 533 times.
✗ Branch 5 not taken.
1066 esGleeok::esGleeok(zfix X,zfix Y,int32_t Id,int32_t Clk, sprite * prnt) : enemy(X,Y,Id,Clk), parent(prnt)
15302 533 {
15303
1/2
✓ Branch 0 taken 533 times.
✗ Branch 1 not taken.
533 xoffset=0;
15304
2/4
✓ Branch 0 taken 533 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 533 times.
✗ Branch 3 not taken.
533 yoffset=(zfix)((dmisc5*4+2));
15305 // dummy_bool[0]=false;
15306 533 timer=0;
15307 /* fixing */
15308 533 hp=1000;
15309
1/2
✓ Branch 0 taken 533 times.
✗ Branch 1 not taken.
533 step=1;
15310 533 item_set=0;
15311 //x=120; y=70;
15312
4/8
✓ Branch 0 taken 533 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 533 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 533 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 533 times.
✗ Branch 7 not taken.
533 x = xoffset+parent->x;
15313
4/8
✓ Branch 0 taken 533 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 533 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 533 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 533 times.
✗ Branch 7 not taken.
533 y = yoffset+parent->y;
15314 533 hxofs=4;
15315 533 hit_width=8;
15316
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 533 times.
✓ Branch 2 taken 533 times.
✗ Branch 3 not taken.
533 yofs=(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
15317 533 clk2=clk; // how int32_t to wait before moving first time
15318 533 clk=0;
15319 533 mainguy=count_enemy=false;
15320
1/2
✓ Branch 0 taken 533 times.
✗ Branch 1 not taken.
533 dir=zc_oldrand();
15321 533 clk3=((dir&2)>>1)+2; // left or right
15322 533 dir&=1; // up or down
15323
1/2
✓ Branch 0 taken 533 times.
✗ Branch 1 not taken.
533 dmisc5=vbound(dmisc5,1,255);
15324 533 isCore = false;
15325
1/2
✓ Branch 0 taken 533 times.
✗ Branch 1 not taken.
533 parentCore = parent->getUID();
15326
2/2
✓ Branch 0 taken 2132 times.
✓ Branch 1 taken 533 times.
2665 for(int32_t i=0; i<dmisc5; i++)
15327 {
15328 2132 nxoffset[i] = 0;
15329 2132 nyoffset[i] = 0;
15330
2/4
✓ Branch 0 taken 2132 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2132 times.
✗ Branch 3 not taken.
2132 nx[i] = ((((i*(int32_t)x) + (dmisc5-i)*((int32_t)parent->x))) /dmisc5);
15331
2/4
✓ Branch 0 taken 2132 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2132 times.
✗ Branch 3 not taken.
2132 ny[i] = ((((i*(int32_t)y) + (dmisc5-i)*((int32_t)parent->y))) /dmisc5);
15332 2132 }
15333
15334 533 necktile=0;
15335 //TODO compatibility? -DD
15336 /*
15337 for(int32_t i=0; i<4; i++)
15338 {
15339 nx[i]=124;
15340 ny[i]=i*6+48;
15341 }*/
15342 533 bgsfx=-1;
15343 //no need for deadsfx
15344 533 }
15345
15346 515535 bool esGleeok::animate(int32_t index)
15347 {
15348
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 515535 times.
515535 if(switch_hooked) return enemy::animate(index);
15349 // don't call removearmos() - it's a segment.
15350
15351 515535 dmisc5=vbound(dmisc5,1,255);
15352
15353
2/2
✓ Branch 0 taken 112773 times.
✓ Branch 1 taken 402762 times.
515535 if(misc == 0)
15354 {
15355 402762 x = (xoffset+parent->x);
15356 402762 y = (yoffset+parent->y);
15357
15358
2/2
✓ Branch 0 taken 1611048 times.
✓ Branch 1 taken 402762 times.
2013810 for(int32_t i=0; i<dmisc5; i++)
15359 {
15360 1611048 nx[i] = ((((i*(int32_t)x) + (dmisc5-i)*((int32_t)parent->x))) /dmisc5) + 3 + nxoffset[i];
15361 1611048 ny[i] = ((((i*(int32_t)y) + (dmisc5-i)*((int32_t)parent->y))) /dmisc5) + nyoffset[i];
15362 1611048 }
15363 402762 }
15364
15365 // set up the head tiles
15366 // headtile=nets+5588; //5580, actually. must adjust for direction later on
15367 /*
15368 if (dummy_bool[0]) //if this is a flame gleeok
15369 {
15370 headtile+=180;
15371 }
15372 */
15373 515535 headtile=dummy_int[2]; //5580, actually. must adjust for direction later on
15374 515535 flyingheadtile=dummy_int[3];
15375
15376 // set up the neck tiles
15377 515535 necktile=dummy_int[1];
15378
15379
2/2
✓ Branch 0 taken 112702 times.
✓ Branch 1 taken 402833 times.
515535 if(get_qr(qr_NEWENEMYTILES))
15380 {
15381 402833 necktile+=((clk&24)>>3);
15382 402833 }
15383
15384 /*
15385 else
15386 {
15387 necktile=145;
15388 }
15389 */
15390 // ?((dummy_bool[0])?(nets+4052+(16+((clk&24)>>3))):(nets+4040+(8+((clk&24)>>3)))):145)
15391
15392
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 402762 times.
✓ Branch 2 taken 112071 times.
✓ Branch 3 taken 300 times.
✓ Branch 4 taken 402 times.
515535 switch(misc)
15393 {
15394 case 0: // live head
15395 // set up the attached head tiles
15396 402762 tile=headtile;
15397
15398
2/2
✓ Branch 0 taken 82942 times.
✓ Branch 1 taken 319820 times.
402762 if(get_qr(qr_NEWENEMYTILES))
15399 {
15400 319820 tile+=((clk&24)>>3);
15401 /*
15402 if (dummy_bool[0]) {
15403 tile+=1561;
15404 }
15405 */
15406 319820 }
15407
15408 /*
15409 else
15410 {
15411 tile=146;
15412 }
15413 */
15414
4/4
✓ Branch 0 taken 104448 times.
✓ Branch 1 taken 298314 times.
✓ Branch 2 taken 11616 times.
✓ Branch 3 taken 92832 times.
402762 if(++clk2>=0 && !(clk2&3))
15415 {
15416
2/2
✓ Branch 0 taken 90773 times.
✓ Branch 1 taken 2059 times.
92832 if(y<= (int32_t)parent->y + 8) dir=down;
15417
15418
2/2
✓ Branch 0 taken 90911 times.
✓ Branch 1 taken 1921 times.
92832 if(y>= (int32_t)parent->y + dmisc5*8) dir = up;
15419
15420
4/4
✓ Branch 0 taken 9757 times.
✓ Branch 1 taken 83075 times.
✓ Branch 2 taken 9465 times.
✓ Branch 3 taken 292 times.
92832 if(y<= (int32_t)parent->y + 10 && !(zc_oldrand()&31))
15421 {
15422 292 dir^=1;
15423 292 }
15424
15425 92832 zfix tempx = x;
15426 92832 zfix tempy = y;
15427
15428 92832 sprite::move(step);
15429 92832 xoffset += (x-tempx);
15430 92832 yoffset += (y-tempy);
15431
15432
2/2
✓ Branch 0 taken 3863 times.
✓ Branch 1 taken 88969 times.
92832 if(clk2>=4)
15433 {
15434 3863 clk3^=1;
15435 3863 clk2=-4;
15436 3863 }
15437 else
15438 {
15439
2/2
✓ Branch 0 taken 87991 times.
✓ Branch 1 taken 978 times.
88969 if(x <= (int32_t)parent->x-(dmisc5*6))
15440 {
15441 978 clk3=right;
15442 978 }
15443
15444
2/2
✓ Branch 0 taken 88008 times.
✓ Branch 1 taken 961 times.
88969 if(x >= (int32_t)parent->x+(dmisc5*6))
15445 {
15446 961 clk3=left;
15447 961 }
15448
15449
4/4
✓ Branch 0 taken 60029 times.
✓ Branch 1 taken 28940 times.
✓ Branch 2 taken 56316 times.
✓ Branch 3 taken 3713 times.
88969 if(y <= (int32_t)parent->y+(dmisc5*6) && !(zc_oldrand()&15))
15450 {
15451 3713 clk3^=1; // x jig
15452 3713 }
15453 else
15454 {
15455
4/4
✓ Branch 0 taken 29223 times.
✓ Branch 1 taken 56033 times.
✓ Branch 2 taken 28372 times.
✓ Branch 3 taken 851 times.
85256 if(y<=(int32_t)parent->y+(dmisc5*4) && !(zc_oldrand()&31))
15456 {
15457 851 clk3^=1; // x switch back
15458 851 }
15459
15460 85256 clk2=-4;
15461 }
15462 }
15463
15464 92832 zc_swap(dir,clk3);
15465 92832 tempx = x;
15466 92832 tempy = y;
15467 92832 sprite::move(step);
15468 92832 xoffset += (x-tempx);
15469 92832 yoffset += (y-tempy);
15470 92832 zc_swap(dir,clk3);
15471
15472
2/2
✓ Branch 0 taken 278496 times.
✓ Branch 1 taken 92832 times.
371328 for(int32_t i=1; i<dmisc5; i++)
15473 {
15474 278496 nxoffset[i] = (zc_oldrand()%3);
15475 278496 nyoffset[i] = (zc_oldrand()%3);
15476 278496 }
15477 92832 }
15478
15479 402762 break;
15480
15481 case 1: // flying head
15482
2/2
✓ Branch 0 taken 6589 times.
✓ Branch 1 taken 105482 times.
112071 if(clk>=0)
15483
15484 {
15485 105482 variable_walk_8(rate,homing,hrate,spw_floater);
15486 105482 }
15487
15488 112071 break;
15489
15490 // the following are messages sent from the main guy...
15491 case -1: // got chopped off
15492 {
15493 300 misc=1;
15494 300 superman=1;
15495 300 hxofs=xofs=0;
15496 300 hit_width=16;
15497 300 cs=8;
15498 300 clk=-24;
15499 300 clk2=40;
15500 300 dir=(zc_oldrand()&7)+8;
15501 300 step=8.0/9.0;
15502 }
15503 300 break;
15504
15505 case -2: // the big guy is dead
15506 402 return true;
15507 }
15508
15509
2/2
✓ Branch 0 taken 475008 times.
✓ Branch 1 taken 40125 times.
515133 if(timer)
15510 {
15511
2/2
✓ Branch 0 taken 35334 times.
✓ Branch 1 taken 4791 times.
40125 if(!(timer%8))
15512 {
15513 4791 FireBreath(true);
15514 4791 }
15515
15516 40125 --timer;
15517 40125 }
15518
15519 515133 return enemy::animate(index);
15520 515535 }
15521
15522 7080 int32_t esGleeok::takehit(weapon *w, weapon* realweap)
15523 {
15524
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 7080 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
7080 if ((editorflags & ENEMY_FLAG7) && misc == 1)
15525 {
15526 int32_t wpnId = w->id;
15527
15528 if(dying)
15529 return 0;
15530
15531 switch(wpnId)
15532 {
15533 case wLitBomb:
15534 case wLitSBomb:
15535 case wBait:
15536 case wWhistle:
15537 case wFire:
15538 case wWind:
15539 case wSSparkle:
15540 case wFSparkle:
15541 case wPhantom:
15542 return 0;
15543
15544 case wHookshot:
15545 case wBrang:
15546 case wBeam:
15547 case wArrow:
15548 case wMagic:
15549 case wBomb:
15550 case wSBomb:
15551 sfx(WAV_CHINK,pan(int32_t(x)));
15552 break;
15553 default:
15554 break;
15555 }
15556
15557 return 1;
15558 }
15559 else
15560 {
15561 7080 int32_t ret = enemy::takehit(w,realweap);
15562
15563
2/2
✓ Branch 0 taken 1425 times.
✓ Branch 1 taken 5655 times.
7080 if(ret==-1)
15564 5655 return 2; // force it to wait a frame before checking sword attacks again
15565
15566 1425 return ret;
15567 }
15568 7080 }
15569
15570 521456 void esGleeok::draw(BITMAP *dest)
15571 {
15572 521456 dmisc5=vbound(dmisc5,1,255);
15573
15574
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 409106 times.
✓ Branch 2 taken 112350 times.
521456 switch(misc)
15575 {
15576 case 0: //neck
15577
1/2
✓ Branch 0 taken 409106 times.
✗ Branch 1 not taken.
409106 if(!dont_draw())
15578 {
15579
2/2
✓ Branch 0 taken 1227318 times.
✓ Branch 1 taken 409106 times.
1636424 for(int32_t i=1; i<dmisc5; i++) //draw the neck
15580 {
15581
2/2
✓ Branch 0 taken 978198 times.
✓ Branch 1 taken 249120 times.
1227318 if(get_qr(qr_NEWENEMYTILES))
15582 {
15583
4/4
✓ Branch 0 taken 23100 times.
✓ Branch 1 taken 955098 times.
✓ Branch 2 taken 20889 times.
✓ Branch 3 taken 2211 times.
978198 if((tmpscr->flags3&fINVISROOM)&& !(current_item(itype_amulet)))
15584 2211 overtilecloaked16(dest,necktile+(i*dmisc7),nx[i]-4,ny[i]+playing_field_offset,0);
15585 else
15586 975987 overtile16(dest,necktile+(i*dmisc7),nx[i]-4,ny[i]+playing_field_offset,cs,0);
15587 978198 }
15588 else
15589 {
15590
3/4
✓ Branch 0 taken 4278 times.
✓ Branch 1 taken 244842 times.
✓ Branch 2 taken 4278 times.
✗ Branch 3 not taken.
249120 if((tmpscr->flags3&fINVISROOM)&& !(current_item(itype_amulet)))
15591 overtilecloaked16(dest,necktile,nx[i]-4,ny[i]+playing_field_offset,0);
15592 else
15593 249120 overtile16(dest,necktile,nx[i]-4,ny[i]+playing_field_offset,cs,0);
15594 }
15595 1227318 }
15596 409106 }
15597
15598 409106 break;
15599
15600 case 1: //flying head
15601 112350 tile=flyingheadtile;
15602
15603
2/2
✓ Branch 0 taken 82692 times.
✓ Branch 1 taken 29658 times.
112350 if(get_qr(qr_NEWENEMYTILES))
15604 {
15605 82692 tile+=((clk&24)>>3);
15606 82692 break;
15607 }
15608
15609 /*
15610 else
15611 {
15612 tile=(clk&1)?147:148;
15613 break;
15614 }
15615 */
15616 29658 }
15617 521456 }
15618
15619 521456 void esGleeok::draw2(BITMAP *dest)
15620 {
15621 521456 enemy::draw(dest);
15622 521456 }
15623
15624 190 ePatra::ePatra(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)// enemy((zfix)128,(zfix)48,Id,Clk)
15625 190 {
15626
1/2
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
190 if ( !(editorflags & ENEMY_FLAG5) )
15627 {
15628
1/2
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
190 x = 128;
15629
1/2
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
190 y = 48;
15630 190 }
15631 else { x = X; y = Y; }
15632 190 adjusted=false;
15633
1/2
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
190 dir=(zc_oldrand()&7)+8;
15634 //step=0.25;
15635 190 flycnt=dmisc1;
15636 190 flycnt2=dmisc2;
15637 190 loopcnt=0;
15638 190 clk4 = 0;
15639 190 clk5 = 0;
15640 190 clk6 = 0;
15641 190 clk7 = 0;
15642
1/2
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
190 if(dmisc6<int16_t(1))dmisc6=1; // ratio cannot be 0!
15643
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 190 times.
190 if (dmisc29 == 0)
15644 {
15645
2/2
✓ Branch 0 taken 85 times.
✓ Branch 1 taken 105 times.
190 if(!dmisc4)
15646 {
15647
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 105 times.
105 if (dmisc10) dmisc29 = (90 / 3);
15648 105 else dmisc29 = (84 / 3);
15649 105 }
15650 else
15651 {
15652
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 85 times.
85 if (dmisc10) dmisc29 = (90 / 2);
15653 85 else dmisc29 = (84 / 2);
15654 }
15655 190 }
15656
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 190 times.
190 if (dmisc30 == 0)
15657 {
15658
2/2
✓ Branch 0 taken 85 times.
✓ Branch 1 taken 105 times.
190 if(!dmisc4)
15659 {
15660
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 105 times.
105 if (dmisc10) dmisc30 = (90 / 3)*0.5;
15661 105 else dmisc30 = (84 / 3)*0.5;
15662 105 }
15663 else
15664 {
15665
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 85 times.
85 if (dmisc10) dmisc30 = (90 / 2)*0.5;
15666 85 else dmisc30 = (84 / 2)*0.5;
15667 }
15668 190 }
15669
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 190 times.
190 if (dmisc31 == 0)
15670 {
15671
2/2
✓ Branch 0 taken 85 times.
✓ Branch 1 taken 105 times.
190 if(!dmisc4)
15672 {
15673
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 105 times.
105 if (dmisc10) dmisc31 = (90 / 3)*2;
15674 105 else dmisc31 = (84 / 3)*2;
15675 105 }
15676 else
15677 {
15678
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 85 times.
85 if (dmisc10) dmisc31 = (90 / 2)*0.5;
15679 85 else dmisc31 = (84 / 2)*0.5;
15680 }
15681 190 }
15682
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 190 times.
190 if (dmisc32 == 0)
15683 {
15684
2/2
✓ Branch 0 taken 85 times.
✓ Branch 1 taken 105 times.
190 if(!dmisc4)
15685 {
15686
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 105 times.
105 if (dmisc10) dmisc32 = (90 / 3);
15687 105 else dmisc32 = (84 / 3);
15688 105 }
15689 else
15690 {
15691
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 85 times.
85 if (dmisc10) dmisc32 = (90 / 2)*0.25;
15692 85 else dmisc32 = (84 / 2)*0.25;
15693 }
15694 190 }
15695
1/2
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
190 init_size_flags();
15696 190 }
15697
15698 161885 bool ePatra::animate(int32_t index)
15699 {
15700
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 161885 times.
161885 if(switch_hooked) return enemy::animate(index);
15701
2/2
✓ Branch 0 taken 1444 times.
✓ Branch 1 taken 160441 times.
161885 if(dying)
15702 {
15703
2/2
✓ Branch 0 taken 72 times.
✓ Branch 1 taken 1444 times.
1516 for(int32_t i=index+1; i<index+flycnt+flycnt2+1; i++)
15704 {
15705 72 ((enemy*)guys.spr(i))->hp = -1000;
15706 72 }
15707
15708 1444 return Dead(index);
15709 }
15710
15711 160441 double basesize = 84;
15712
1/2
✓ Branch 0 taken 160441 times.
✗ Branch 1 not taken.
160441 if (dmisc10) basesize = 90;
15713 160441 double halfsize = basesize / 2;
15714 160441 double quartersize = halfsize / 2;
15715 160441 double twothirdsize = (basesize / 3)*2;
15716 160441 double onethirdsize = (basesize / 3);
15717
15718
15719
2/2
✓ Branch 0 taken 123507 times.
✓ Branch 1 taken 36934 times.
160441 if(clk==0)
15720 {
15721 36934 removearmos(x,y,ffcactivated);
15722 36934 }
15723
15724
2/6
✗ Branch 0 not taken.
✓ Branch 1 taken 160441 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 160441 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
160441 if ((clk4 <=0 || clk4%2) && (clk7 <= 0 || clk6 <= -16))
15725 {
15726
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 160441 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
160441 if (!dmisc22 || loopcnt == 0 || (dmisc22 == 1 && loopcnt < 0)) variable_walk_8(rate,homing,hrate,spw_floater);
15727
1/2
✓ Branch 0 taken 160441 times.
✗ Branch 1 not taken.
160441 if (loopcnt < 0) ++clk2;
15728
2/2
✓ Branch 0 taken 158644 times.
✓ Branch 1 taken 1797 times.
160441 if(++clk2>basesize)
15729 {
15730 1797 clk2=0;
15731
2/12
✗ Branch 0 not taken.
✓ Branch 1 taken 1797 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 1797 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
1797 if ((!dmisc26 || (dmisc26 == 1 && flycnt) || (dmisc26 == 2 && !flycnt)) && (!(editorflags & ENEMY_FLAG10) || flycnt || flycnt2))
15732 {
15733
2/2
✓ Branch 0 taken 932 times.
✓ Branch 1 taken 865 times.
1797 if(loopcnt > 0)
15734 932 --loopcnt;
15735
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 865 times.
865 else if (loopcnt == 0)
15736 {
15737
2/2
✓ Branch 0 taken 509 times.
✓ Branch 1 taken 356 times.
865 if((misc%dmisc6)==0)
15738 {
15739
1/2
✓ Branch 0 taken 356 times.
✗ Branch 1 not taken.
356 if (dmisc21 > 0) loopcnt=-dmisc21;
15740 356 else loopcnt=dmisc7;
15741 356 }
15742 865 }
15743 else if (loopcnt == -1) loopcnt=dmisc7;
15744 else ++loopcnt;
15745
15746
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1797 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1797 if (!(editorflags & ENEMY_FLAG9) || loopcnt == 0) ++misc;
15747 1797 }
15748 else
15749 {
15750 loopcnt = 0;
15751 misc = 1;
15752 }
15753 1797 }
15754 160441 }
15755
1/2
✓ Branch 0 taken 160441 times.
✗ Branch 1 not taken.
160441 if (clk4 > 0) --clk4;
15756
15757
1/2
✓ Branch 0 taken 160441 times.
✗ Branch 1 not taken.
160441 if (clk6 < 0)
15758 {
15759 if (dmisc5 == 1 || dmisc5 == 3)
15760 {
15761 if (get_qr(qr_NEWENEMYTILES))
15762 {
15763 if (clk7 <= 0 || clk6 != -16) ++clk6;
15764 if (clk6 == 0) o_tile=d->e_tile;
15765 else
15766 {
15767 if (clk6 >= -16) o_tile=d->e_tile + (IsBigAnim() ? 320 : 80);
15768 else o_tile=d->e_tile + (IsBigAnim() ? 160 : 40);
15769 }
15770 }
15771 else clk6 = 0;
15772 }
15773 }
15774
1/2
✓ Branch 0 taken 160441 times.
✗ Branch 1 not taken.
160441 else if (dmisc19) ++clk6;
15775
1/2
✓ Branch 0 taken 160441 times.
✗ Branch 1 not taken.
160441 if (clk5 < 0) ++clk5;
15776
1/2
✓ Branch 0 taken 160441 times.
✗ Branch 1 not taken.
160441 else if (dmisc19) ++clk5;
15777
15778
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 160441 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
160441 if (clk7 > 0 && clk6 >= -16) --clk7;
15779
1/2
✓ Branch 0 taken 160441 times.
✗ Branch 1 not taken.
160441 if (clk6 > 0) clk7 = 0;
15780
15781
2/2
✓ Branch 0 taken 660384 times.
✓ Branch 1 taken 160441 times.
820825 for(int32_t i=index+1; i<index+flycnt+1; i++)
15782 {
15783 //outside ring
15784
2/2
✓ Branch 0 taken 659040 times.
✓ Branch 1 taken 1344 times.
660384 if(!adjusted)
15785 {
15786
2/2
✓ Branch 0 taken 1152 times.
✓ Branch 1 taken 192 times.
1344 if(get_qr(qr_NEWENEMYTILES))
15787 {
15788 1152 ((enemy*)guys.spr(i))->o_tile=d->e_tile+dmisc8;
15789 1152 enemy *s = ((enemy*)guys.spr(i));
15790 1152 s->parent_script_UID = this->script_UID;
15791 1152 }
15792 else
15793 {
15794 192 ((enemy*)guys.spr(i))->o_tile=o_tile+1;
15795 192 enemy *s = ((enemy*)guys.spr(i));
15796 192 s->parent_script_UID = this->script_UID;
15797 }
15798
15799 1344 ((enemy*)guys.spr(i))->cs=dmisc9;
15800 1344 ((enemy*)guys.spr(i))->hp=dmisc3;
15801 1344 }
15802
15803
2/2
✓ Branch 0 taken 764 times.
✓ Branch 1 taken 659620 times.
660384 if(((enemy*)guys.spr(i))->hp <= 0)
15804 {
15805
2/2
✓ Branch 0 taken 2889 times.
✓ Branch 1 taken 764 times.
3653 for(int32_t j=i; j<index+flycnt+flycnt2; j++)
15806 {
15807 2889 guys.swap(j,j+1);
15808 2889 }
15809
15810
3/4
✓ Branch 0 taken 94 times.
✓ Branch 1 taken 670 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 94 times.
764 if (--flycnt == 0 && dmisc23 != 0) step += zslongToFix(dmisc23*100);
15811 764 }
15812 else
15813 {
15814 659620 int32_t pos2 = ((enemy*)guys.spr(i))->misc;
15815
1/2
✓ Branch 0 taken 659620 times.
✗ Branch 1 not taken.
659620 double a2 = (clk2-pos2*(double)basesize/(dmisc1 == 0 ? 1 : dmisc1))*PI/halfsize;
15816
15817
2/2
✓ Branch 0 taken 212037 times.
✓ Branch 1 taken 447583 times.
659620 if(!dmisc4) //Big Ring
15818 {
15819 //maybe playing_field_offset here?
15820
2/2
✓ Branch 0 taken 237330 times.
✓ Branch 1 taken 210253 times.
447583 if(loopcnt>0)
15821 {
15822
1/2
✓ Branch 0 taken 237330 times.
✗ Branch 1 not taken.
237330 guys.spr(i)->x = zc::math::Cos(a2+PI/2)*abs(dmisc31) - zc::math::Sin(pos2*PI*2/(dmisc1 == 0 ? 1 : dmisc1))*((int64_t)abs(dmisc31)-abs(dmisc29));
15823
1/2
✓ Branch 0 taken 237330 times.
✗ Branch 1 not taken.
237330 guys.spr(i)->y = -zc::math::Sin(a2+PI/2)*abs(dmisc31) + zc::math::Cos(pos2*PI*2/(dmisc1 == 0 ? 1 : dmisc1))*((int64_t)abs(dmisc31)-abs(dmisc29));
15824 237330 }
15825 else
15826 {
15827 210253 guys.spr(i)->x = zc::math::Cos(a2+PI/2)*abs(dmisc29);
15828 210253 guys.spr(i)->y = -zc::math::Sin(a2+PI/2)*abs(dmisc29);
15829 }
15830
15831 447583 temp_x=guys.spr(i)->x;
15832 447583 temp_y=guys.spr(i)->y;
15833 447583 }
15834 else //Oval
15835 {
15836 212037 circle_x = zc::math::Cos(a2+PI/2)*abs(dmisc29);
15837 212037 circle_y = -zc::math::Sin(a2+PI/2)*abs(dmisc29);
15838
15839
2/2
✓ Branch 0 taken 121041 times.
✓ Branch 1 taken 90996 times.
212037 if(loopcnt>0)
15840 {
15841 121041 guys.spr(i)->x = zc::math::Cos(a2+PI/2)*abs(dmisc29);
15842
1/2
✓ Branch 0 taken 121041 times.
✗ Branch 1 not taken.
121041 guys.spr(i)->y = (-zc::math::Sin(a2+PI/2)-zc::math::Cos(pos2*PI*2/(dmisc1 == 0 ? 1 : dmisc1)))*abs(dmisc31);
15843 121041 }
15844 else
15845 {
15846 90996 guys.spr(i)->x = circle_x;
15847 90996 guys.spr(i)->y = circle_y;
15848 }
15849
15850 212037 temp_x=circle_x;
15851 212037 temp_y=circle_y;
15852 }
15853
15854 double _MSVC2022_tmp1, _MSVC2022_tmp2;
15855 659620 double ddir=atan2_MSVC2022_FIX(double(temp_y),double(temp_x));
15856
15857
4/4
✓ Branch 0 taken 124008 times.
✓ Branch 1 taken 535612 times.
✓ Branch 2 taken 40891 times.
✓ Branch 3 taken 83117 times.
659620 if((ddir<=(((-5)*PI)/8))&&(ddir>(((-7)*PI)/8)))
15858 {
15859 83117 guys.spr(i)->dir=l_down;
15860 83117 }
15861
4/4
✓ Branch 0 taken 124459 times.
✓ Branch 1 taken 452044 times.
✓ Branch 2 taken 40891 times.
✓ Branch 3 taken 83568 times.
576503 else if((ddir<=(((-3)*PI)/8))&&(ddir>(((-5)*PI)/8)))
15862 {
15863 83568 guys.spr(i)->dir=left;
15864 83568 }
15865
4/4
✓ Branch 0 taken 123345 times.
✓ Branch 1 taken 369590 times.
✓ Branch 2 taken 40891 times.
✓ Branch 3 taken 82454 times.
492935 else if((ddir<=(((-1)*PI)/8))&&(ddir>(((-3)*PI)/8)))
15866 {
15867 82454 guys.spr(i)->dir=l_up;
15868 82454 }
15869
4/4
✓ Branch 0 taken 123079 times.
✓ Branch 1 taken 287402 times.
✓ Branch 2 taken 40891 times.
✓ Branch 3 taken 82188 times.
410481 else if((ddir<=(((1)*PI)/8))&&(ddir>(((-1)*PI)/8)))
15870 {
15871 82188 guys.spr(i)->dir=up;
15872 82188 }
15873
4/4
✓ Branch 0 taken 122491 times.
✓ Branch 1 taken 205802 times.
✓ Branch 2 taken 40891 times.
✓ Branch 3 taken 81600 times.
328293 else if((ddir<=(((3)*PI)/8))&&(ddir>(((1)*PI)/8)))
15874 {
15875 81600 guys.spr(i)->dir=r_up;
15876 81600 }
15877
4/4
✓ Branch 0 taken 122884 times.
✓ Branch 1 taken 123809 times.
✓ Branch 2 taken 40891 times.
✓ Branch 3 taken 81993 times.
246693 else if((ddir<=(((5)*PI)/8))&&(ddir>(((3)*PI)/8)))
15878 {
15879 81993 guys.spr(i)->dir=right;
15880 81993 }
15881
4/4
✓ Branch 0 taken 122590 times.
✓ Branch 1 taken 42110 times.
✓ Branch 2 taken 40891 times.
✓ Branch 3 taken 81699 times.
164700 else if((ddir<=(((7)*PI)/8))&&(ddir>(((5)*PI)/8)))
15882 {
15883 81699 guys.spr(i)->dir=r_down;
15884 81699 }
15885 else
15886 {
15887 83001 guys.spr(i)->dir=down;
15888 }
15889
15890 659620 guys.spr(i)->x += x;
15891 659620 guys.spr(i)->y += y;
15892 }
15893 660384 }
15894
15895
7/22
✓ Branch 0 taken 106957 times.
✓ Branch 1 taken 53484 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 106957 times.
✓ Branch 4 taken 21153 times.
✓ Branch 5 taken 32331 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 21153 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 32331 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
160441 if((wpn>wEnemyWeapons || (wpn >= wScript1 && wpn <= wScript10)) && (dmisc5==1 || dmisc5== 3) && (!dmisc25 || (dmisc25 == 1 && !flycnt && !flycnt2) || (dmisc25 == 2 && (flycnt || flycnt2)) || (dmisc25 == 3 && flycnt2 && !flycnt)))
15896 {
15897 32331 int timeneeded = 48;
15898 32331 int patbreath = (zc_oldrand()%50+50);
15899
2/2
✓ Branch 0 taken 24549 times.
✓ Branch 1 taken 7782 times.
32331 if ((patbreath % 4) == 0) ++patbreath;
15900
1/2
✓ Branch 0 taken 32331 times.
✗ Branch 1 not taken.
32331 if (dmisc28 == patratBREATH)
15901 {
15902 timeneeded = 48 + patbreath;
15903 }
15904
1/2
✓ Branch 0 taken 32331 times.
✗ Branch 1 not taken.
32331 if (dmisc28 == patratSTREAM)
15905 {
15906 timeneeded = 48 + 96;
15907 }
15908
4/14
✓ Branch 0 taken 32331 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 32331 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✓ Branch 10 taken 249 times.
✓ Branch 11 taken 249 times.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
32331 if (((((dmisc18 > 0 || ((editorflags & ENEMY_FLAG10) && !flycnt && !flycnt2)) && !(zc_oldrand() % zc_max(dmisc18, 1))) || //New 1/N chance
15909
2/2
✓ Branch 0 taken 32331 times.
✓ Branch 1 taken 249 times.
32580 (dmisc18 == 0 && !(zc_oldrand()&127)) //Old hardcoded firing chance
15910
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 32082 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
32580 || (dmisc18 == -1 && loopcnt > 0 && (clk2 == round(halfsize) && (!(editorflags & ENEMY_FLAG3) || !get_qr(qr_NEWENEMYTILES))
15911 || (clk4 == 10 && (editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES)))))
15912 249 && (clk6 >= 0) //if not in the middle of firing...
15913 249 && clk6 >= dmisc19) //if over the set cooldown between shots...
15914
2/6
✓ Branch 0 taken 249 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 249 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
249 && ((!(editorflags & ENEMY_FLAG7) || (loopcnt == 0 && (basesize*((int64_t)dmisc6 - (misc%dmisc6))) > timeneeded)) || dmisc18 == -1)) //And lastly, if not in danger of starting a loop during the attack.
15915 {
15916
1/3
✓ Branch 0 taken 249 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
249 switch(dmisc28)
15917 {
15918 case patratSTREAM:
15919 {
15920 clk7 = 97;
15921 if ((editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES)) clk6 = -48;
15922 else clk6 = 0;
15923 break;
15924 }
15925 case patratBREATH:
15926 {
15927 clk7 = patbreath;
15928 if ((editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES)) clk6 = -48;
15929 else clk6 = 0;
15930 break;
15931 }
15932 default:
15933 {
15934
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 249 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
249 if ((editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES))
15935 {
15936 clk6 = -48;
15937 if (editorflags & ENEMY_FLAG6) clk4 = abs(clk6) + 16;
15938 }
15939 else
15940 {
15941 249 clk6 = 0;
15942
1/2
✓ Branch 0 taken 249 times.
✗ Branch 1 not taken.
249 if (editorflags & ENEMY_FLAG6) clk4 = 16;
15943 249 FirePatraWeapon();
15944 }
15945 249 break;
15946 }
15947 } //ew->setAngle(atan2(double(HeroY()-y),double(HeroX()-x)));
15948 249 }
15949
1/2
✓ Branch 0 taken 32331 times.
✗ Branch 1 not taken.
32331 if (clk6 < 0)
15950 {
15951 switch(dmisc28)
15952 {
15953 case patratSTREAM:
15954 {
15955 if (clk7 > 0 && (clk7 % 12) == 0) FirePatraWeapon();
15956 if (editorflags & ENEMY_FLAG6) clk4 = abs(clk6) + 16;
15957 break;
15958 }
15959 case patratBREATH:
15960 {
15961 if (clk7 > 0 && (clk7 % 4) == 0) FirePatraWeapon();
15962 if (editorflags & ENEMY_FLAG6) clk4 = abs(clk6) + 16;
15963 break;
15964 }
15965 default:
15966 {
15967 if ((editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES) && clk6 == -16)
15968 {
15969 FirePatraWeapon();
15970 if (editorflags & ENEMY_FLAG6) clk4 = abs(clk6) + 16;
15971 }
15972 break;
15973 }
15974 }
15975 }
15976 32331 }
15977
15978 160441 int randattempts = 0;
15979 160441 int randeye = 0;
15980
2/2
✓ Branch 0 taken 114201 times.
✓ Branch 1 taken 46240 times.
160441 if (flycnt2 > 0)
15981 {
15982 46240 do
15983 {
15984
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 46240 times.
✓ Branch 2 taken 44221 times.
✓ Branch 3 taken 2019 times.
46240 randeye = ((flycnt2 > 0) ? (zc_oldrand() % zc_max(1, flycnt2)) : 0);
15985 46240 randeye += (index + flycnt + 1);
15986 46240 ++randattempts;
15987
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 46240 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 46240 times.
46240 } while (((esPatra*)guys.spr(randeye))->clk5 < 0 && randattempts < 10);
15988 46240 }
15989 160441 bool dofire = false;
15990
1/2
✓ Branch 0 taken 160441 times.
✗ Branch 1 not taken.
160441 if (dmisc20)
15991 {
15992 if ((dmisc18 > 0 && !(zc_oldrand() % zc_max(dmisc18, 1))) ||
15993 (dmisc18 == 0 && !(zc_oldrand()&127)) ||
15994 (dmisc18 == -1 && (loopcnt > 0 || dmisc20 == 4) && ((clk2 == round(halfsize) && (!(editorflags & ENEMY_FLAG3) || !get_qr(qr_NEWENEMYTILES)) && dmisc20 != 2 && dmisc20 != 4)
15995 || (clk2 == 10 && dmisc20 != 4 && ((editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES) || dmisc20 == 2))
15996 || ((((((misc%dmisc6) == 0 && (loopcnt == 0 && !dmisc21)) || loopcnt > 1 || loopcnt == -1) && clk2 <= 53 && clk2 >= 51 && (editorflags & ENEMY_FLAG3)) || (!(editorflags & ENEMY_FLAG3) && loopcnt > 0 && clk2 == 1)) && dmisc20 == 4))))
15997 {
15998 if (clk5 >= 0 || !(editorflags & ENEMY_FLAG3) || !get_qr(qr_NEWENEMYTILES))
15999 {
16000 if (clk5 >= dmisc19)
16001 {
16002 if ((!(editorflags & ENEMY_FLAG7) || (loopcnt == 0 &&
16003 (dmisc20 == 2 && (basesize*((int64_t)dmisc6 - (misc%dmisc6))) > ((int64_t)48 + (int64_t(12)*flycnt2))) ||
16004 (dmisc20 == 4 && (basesize*((int64_t)dmisc6 - (misc%dmisc6))) > ((int64_t)48 + 96)) ||
16005 (dmisc20 != 2 && dmisc20 != 4 && (basesize*((int64_t)dmisc6 - (misc%dmisc6))) > 48)))
16006 || dmisc18 == -1)
16007 dofire = true;
16008 }
16009 }
16010 }
16011 }
16012
2/2
✓ Branch 0 taken 114201 times.
✓ Branch 1 taken 46240 times.
160441 if(flycnt2)
16013 {
16014
2/2
✓ Branch 0 taken 334429 times.
✓ Branch 1 taken 46240 times.
380669 for(int32_t i=index+flycnt+1; i<index+flycnt+flycnt2+1; i++)//inner ring
16015 {
16016
2/2
✓ Branch 0 taken 334117 times.
✓ Branch 1 taken 312 times.
334429 if(!adjusted)
16017 {
16018 312 ((enemy*)guys.spr(i))->hp=12*game->get_hero_dmgmult();
16019
16020
1/2
✓ Branch 0 taken 312 times.
✗ Branch 1 not taken.
312 if(get_qr(qr_NEWENEMYTILES))
16021 {
16022
1/2
✓ Branch 0 taken 312 times.
✗ Branch 1 not taken.
312 if (get_qr(qr_PATRAS_USE_HARDCODED_OFFSETS))
16023 {
16024
2/3
✓ Branch 0 taken 144 times.
✓ Branch 1 taken 168 times.
✗ Branch 2 not taken.
312 switch(dmisc5)
16025 {
16026 // Center eye shoots projectiles; make room for its firing tiles
16027 case 1:
16028 case 3:
16029 144 ((enemy*)guys.spr(i))->o_tile=d->e_tile+120;
16030 144 break;
16031
16032 // Center eyes does not shoot; use tiles two rows below for inner eyes.
16033 default:
16034 case 2:
16035 168 ((enemy*)guys.spr(i))->o_tile=d->e_tile+40;
16036 168 break;
16037 }
16038 312 }
16039 else ((enemy*)guys.spr(i))->o_tile = d->s_tile;
16040 312 }
16041 else
16042 {
16043 ((enemy*)guys.spr(i))->o_tile=o_tile+1;
16044 }
16045
16046 312 ((enemy*)guys.spr(i))->cs=dmisc9;
16047
1/2
✓ Branch 0 taken 312 times.
✗ Branch 1 not taken.
312 if (dmisc27) ((enemy*)guys.spr(i))->hp=dmisc27;
16048 312 }
16049
16050
2/2
✓ Branch 0 taken 263816 times.
✓ Branch 1 taken 70613 times.
334429 if(flycnt>0)
16051 {
16052 263816 ((enemy*)guys.spr(i))->superman=true;
16053 263816 }
16054 else
16055 {
16056 70613 ((enemy*)guys.spr(i))->superman=false;
16057 }
16058
16059
2/2
✓ Branch 0 taken 145 times.
✓ Branch 1 taken 334284 times.
334429 if(((enemy*)guys.spr(i))->hp <= 0)
16060 {
16061
2/2
✓ Branch 0 taken 269 times.
✓ Branch 1 taken 145 times.
414 for(int32_t j=i; j<index+flycnt+flycnt2; j++)
16062 {
16063 269 guys.swap(j,j+1);
16064 269 }
16065
16066
3/4
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 127 times.
✓ Branch 2 taken 18 times.
✗ Branch 3 not taken.
145 if (--flycnt2 == 0 && dmisc24 != 0) step += zslongToFix(dmisc24*100);
16067 145 }
16068 else
16069 {
16070 334284 int32_t pos2 = ((enemy*)guys.spr(i))->misc;
16071
1/2
✓ Branch 0 taken 334284 times.
✗ Branch 1 not taken.
334284 double a2 = ((clk2-pos2*basesize/(dmisc2==0 ? 1 : dmisc2))*PI/(halfsize));
16072
16073
2/2
✓ Branch 0 taken 7259 times.
✓ Branch 1 taken 327025 times.
334284 if(dmisc4==0)
16074 {
16075
2/2
✓ Branch 0 taken 168378 times.
✓ Branch 1 taken 158647 times.
327025 if(loopcnt>0)
16076 {
16077
1/2
✓ Branch 0 taken 168378 times.
✗ Branch 1 not taken.
168378 guys.spr(i)->x = zc::math::Cos(a2+PI/2)*abs(dmisc32) - zc::math::Sin(pos2*PI*2/(dmisc2==0?1:dmisc2))*((int64_t)abs(dmisc32)-abs(dmisc30));
16078
1/2
✓ Branch 0 taken 168378 times.
✗ Branch 1 not taken.
168378 guys.spr(i)->y = -zc::math::Sin(a2+PI/2)*abs(dmisc32) + zc::math::Cos(pos2*PI*2/(dmisc2==0?1:dmisc2))*((int64_t)abs(dmisc32)-abs(dmisc30));
16079 168378 }
16080 else
16081 {
16082 158647 guys.spr(i)->x = zc::math::Cos(a2+PI/2)*abs(dmisc30);
16083 158647 guys.spr(i)->y = -zc::math::Sin(a2+PI/2)*abs(dmisc30);
16084 }
16085
16086 327025 temp_x=guys.spr(i)->x;
16087 327025 temp_y=guys.spr(i)->y;
16088 327025 }
16089 else
16090 {
16091 7259 circle_x = zc::math::Cos(a2+PI/2)*abs(dmisc30);
16092 7259 circle_y = -zc::math::Sin(a2+PI/2)*abs(dmisc30);
16093
16094
2/2
✓ Branch 0 taken 3965 times.
✓ Branch 1 taken 3294 times.
7259 if(loopcnt>0)
16095 {
16096 3965 guys.spr(i)->x = zc::math::Cos(a2+PI/2)*abs(dmisc30);
16097
1/2
✓ Branch 0 taken 3965 times.
✗ Branch 1 not taken.
3965 guys.spr(i)->y = (-zc::math::Sin(a2+PI/2)-zc::math::Cos(pos2*PI*2/(dmisc2 == 0 ? 1 : dmisc2)))*abs(dmisc32);
16098 3965 }
16099 else
16100 {
16101 3294 guys.spr(i)->x = circle_x;
16102 3294 guys.spr(i)->y = circle_y;
16103 }
16104
16105 7259 temp_x=circle_x;
16106 7259 temp_y=circle_y;
16107 }
16108
16109 double _MSVC2022_tmp1, _MSVC2022_tmp2;
16110 334284 double ddir=atan2_MSVC2022_FIX(double(temp_y),double(temp_x));
16111
16112
4/4
✓ Branch 0 taken 61619 times.
✓ Branch 1 taken 272665 times.
✓ Branch 2 taken 19873 times.
✓ Branch 3 taken 41746 times.
334284 if((ddir<=(((-5)*PI)/8))&&(ddir>(((-7)*PI)/8)))
16113 {
16114 41746 guys.spr(i)->dir=l_down;
16115 41746 }
16116
4/4
✓ Branch 0 taken 61607 times.
✓ Branch 1 taken 230931 times.
✓ Branch 2 taken 19873 times.
✓ Branch 3 taken 41734 times.
292538 else if((ddir<=(((-3)*PI)/8))&&(ddir>(((-5)*PI)/8)))
16117 {
16118 41734 guys.spr(i)->dir=left;
16119 41734 }
16120
4/4
✓ Branch 0 taken 61615 times.
✓ Branch 1 taken 189189 times.
✓ Branch 2 taken 19873 times.
✓ Branch 3 taken 41742 times.
250804 else if((ddir<=(((-1)*PI)/8))&&(ddir>(((-3)*PI)/8)))
16121 {
16122 41742 guys.spr(i)->dir=l_up;
16123 41742 }
16124
4/4
✓ Branch 0 taken 61631 times.
✓ Branch 1 taken 147431 times.
✓ Branch 2 taken 19873 times.
✓ Branch 3 taken 41758 times.
209062 else if((ddir<=(((1)*PI)/8))&&(ddir>(((-1)*PI)/8)))
16125 {
16126 41758 guys.spr(i)->dir=up;
16127 41758 }
16128
4/4
✓ Branch 0 taken 61703 times.
✓ Branch 1 taken 105601 times.
✓ Branch 2 taken 19873 times.
✓ Branch 3 taken 41830 times.
167304 else if((ddir<=(((3)*PI)/8))&&(ddir>(((1)*PI)/8)))
16129 {
16130 41830 guys.spr(i)->dir=r_up;
16131 41830 }
16132
4/4
✓ Branch 0 taken 61697 times.
✓ Branch 1 taken 63777 times.
✓ Branch 2 taken 19873 times.
✓ Branch 3 taken 41824 times.
125474 else if((ddir<=(((5)*PI)/8))&&(ddir>(((3)*PI)/8)))
16133 {
16134 41824 guys.spr(i)->dir=right;
16135 41824 }
16136
4/4
✓ Branch 0 taken 61725 times.
✓ Branch 1 taken 21925 times.
✓ Branch 2 taken 19873 times.
✓ Branch 3 taken 41852 times.
83650 else if((ddir<=(((7)*PI)/8))&&(ddir>(((5)*PI)/8)))
16137 {
16138 41852 guys.spr(i)->dir=r_down;
16139 41852 }
16140 else
16141 {
16142 41798 guys.spr(i)->dir=down;
16143 }
16144
16145 334284 guys.spr(i)->x += x;
16146 334284 guys.spr(i)->y = y-guys.spr(i)->y;
16147
16148
4/8
✗ Branch 0 not taken.
✓ Branch 1 taken 334284 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 189016 times.
✓ Branch 5 taken 145268 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 189016 times.
334284 if((wpn>wEnemyWeapons || (wpn >= wScript1 && wpn <= wScript10)) && (dmisc5==2 || dmisc5== 3))
16149 {
16150 /*
16151 if(!(zc_oldrand()&127))
16152 {
16153 addEwpn(guys.spr(i)->x,guys.spr(i)->y,guys.spr(i)->z,wpn,3,wdp,dir,getUID());
16154 sfx(wpnsfx(wpn),pan(int32_t(x)));
16155 }
16156 */
16157
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 145268 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
145268 if (((esPatra*)guys.spr(i))->clk5 < 0 && (editorflags & ENEMY_FLAG3))
16158 {
16159 if (((esPatra*)guys.spr(i))->clk4 <= 0 || ((esPatra*)guys.spr(i))->clk5 != -16) ++((esPatra*)guys.spr(i))->clk5;
16160 if (get_qr(qr_PATRAS_USE_HARDCODED_OFFSETS))
16161 {
16162 if (dmisc5 == 3)
16163 {
16164 if (((esPatra*)guys.spr(i))->clk5 >= 0) ((esPatra*)guys.spr(i))->o_tile=d->e_tile+120;
16165 else if (((esPatra*)guys.spr(i))->clk5 >= -16) ((esPatra*)guys.spr(i))->o_tile=d->e_tile+200;
16166 else if (((esPatra*)guys.spr(i))->clk5 >= -48) ((esPatra*)guys.spr(i))->o_tile=d->e_tile+160;
16167 else ((esPatra*)guys.spr(i))->o_tile=d->e_tile+120;
16168 }
16169 else
16170 {
16171 if (((esPatra*)guys.spr(i))->clk5 >= 0) ((esPatra*)guys.spr(i))->o_tile=d->e_tile+40;
16172 else if (((esPatra*)guys.spr(i))->clk5 >= -16) ((esPatra*)guys.spr(i))->o_tile=d->e_tile+120;
16173 else if (((esPatra*)guys.spr(i))->clk5 >= -48) ((esPatra*)guys.spr(i))->o_tile=d->e_tile+80;
16174 else ((esPatra*)guys.spr(i))->o_tile=d->e_tile+40;
16175 }
16176 }
16177 else
16178 {
16179 if (((esPatra*)guys.spr(i))->clk5 >= 0) ((esPatra*)guys.spr(i))->o_tile=d->s_tile;
16180 else if (((esPatra*)guys.spr(i))->clk5 >= -16) ((esPatra*)guys.spr(i))->o_tile=d->s_tile+80;
16181 else if (((esPatra*)guys.spr(i))->clk5 >= -48) ((esPatra*)guys.spr(i))->o_tile=d->s_tile+40;
16182 else ((esPatra*)guys.spr(i))->o_tile=d->s_tile;
16183 }
16184 }
16185
4/6
✓ Branch 0 taken 145268 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 145268 times.
✓ Branch 4 taken 145268 times.
✓ Branch 5 taken 145268 times.
145268 else if ((dmisc19 || ((esPatra*)guys.spr(i))->clk5) && (((esPatra*)guys.spr(i))->clk4 <= 0 || ((esPatra*)guys.spr(i))->clk5 != -16)) ++((esPatra*)guys.spr(i))->clk5;
16186
1/2
✓ Branch 0 taken 145268 times.
✗ Branch 1 not taken.
145268 if (((esPatra*)guys.spr(i))->clk4 > 0) --((esPatra*)guys.spr(i))->clk4;
16187
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 145268 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
145268 if (!dmisc25 || (dmisc25 == 1 && !((enemy*)guys.spr(i))->superman) || ((dmisc25 == 2 || dmisc25 == 3) && ((enemy*)guys.spr(i))->superman))
16188 {
16189
1/5
✓ Branch 0 taken 145268 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
145268 switch(dmisc20) //Patra Attack Patterns
16190 {
16191 case 4: //Single one rapidfires
16192 {
16193 if (dofire && i == randeye)
16194 {
16195 ((esPatra*)guys.spr(i))->clk5 = -16;
16196 if ((editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES)) ((esPatra*)guys.spr(i))->clk5 = -48;
16197 ((esPatra*)guys.spr(i))->clk4 = 96;
16198 clk5 = -3;
16199 if (editorflags & ENEMY_FLAG6) clk4 = abs(clk5) + 16;
16200 }
16201 if (((esPatra*)guys.spr(i))->clk5 == -16 && (((esPatra*)guys.spr(i))->clk4 % 12) == 0)
16202 {
16203 addEwpn(guys.spr(i)->x,guys.spr(i)->y,guys.spr(i)->z,wpn,3,wdp,dir,getUID(), 0, guys.spr(i)->fakez);
16204 sfx(wpnsfx(wpn),pan(int32_t(x)));
16205 }
16206 break;
16207 }
16208 case 3: //Ring
16209 {
16210 if (dofire)
16211 {
16212 if ((editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES))
16213 {
16214 ((esPatra*)guys.spr(i))->clk5 = -48;
16215 clk5 = -48;
16216 if (editorflags & ENEMY_FLAG6) clk4 = 64;
16217 }
16218 else
16219 {
16220 addEwpn(guys.spr(i)->x,guys.spr(i)->y,guys.spr(i)->z,wpn,3,wdp,dir,getUID(), 0, guys.spr(i)->fakez);
16221 sfx(wpnsfx(wpn),pan(int32_t(x)));
16222 int32_t m=Ewpns.Count()-1;
16223 weapon *ew = (weapon*)(Ewpns.spr(m));
16224
16225 ew->setAngle(atan2(double(HeroY()-y),double(HeroX()-x)));
16226 ((esPatra*)guys.spr(i))->clk5 = 0;
16227 clk5 = 0;
16228 if (editorflags & ENEMY_FLAG6) clk4 = 16;
16229 }
16230 }
16231 if (((esPatra*)guys.spr(i))->clk5 == -16)
16232 {
16233 addEwpn(guys.spr(i)->x,guys.spr(i)->y,guys.spr(i)->z,wpn,3,wdp,dir,getUID(), 0, guys.spr(i)->fakez);
16234 sfx(wpnsfx(wpn),pan(int32_t(x)));
16235 int32_t m=Ewpns.Count()-1;
16236 weapon *ew = (weapon*)(Ewpns.spr(m));
16237
16238 ew->setAngle(atan2(double(HeroY()-y),double(HeroX()-x)));
16239 }
16240 break;
16241 }
16242 case 2: //one after another
16243 {
16244 if (dofire)
16245 {
16246 ((esPatra*)guys.spr(i))->clk5 = -48 - (12*(i-(index+flycnt+1)));
16247 clk5 = -48 - (12*flycnt2);
16248 if (editorflags & ENEMY_FLAG6) clk4 = abs(clk5) + 16;
16249 }
16250 if (((esPatra*)guys.spr(i))->clk5 == -16)
16251 {
16252 addEwpn(guys.spr(i)->x,guys.spr(i)->y,guys.spr(i)->z,wpn,3,wdp,dir,getUID(), 0, guys.spr(i)->fakez);
16253 sfx(wpnsfx(wpn),pan(int32_t(x)));
16254 }
16255 break;
16256 }
16257 case 1: //random one eye
16258 {
16259 if (dofire && i == randeye)
16260 {
16261 if ((editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES))
16262 {
16263 ((esPatra*)guys.spr(i))->clk5 = -48;
16264 clk5 = -48;
16265 if (editorflags & ENEMY_FLAG6) clk4 = 64;
16266 }
16267 else
16268 {
16269 addEwpn(guys.spr(i)->x,guys.spr(i)->y,guys.spr(i)->z,wpn,3,wdp,dir,getUID(), 0, guys.spr(i)->fakez);
16270 sfx(wpnsfx(wpn),pan(int32_t(x)));
16271 ((esPatra*)guys.spr(i))->clk5 = 0;
16272 clk5 = 0;
16273 if (editorflags & ENEMY_FLAG6) clk4 = 16;
16274 }
16275 }
16276 if ((editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES) && ((esPatra*)guys.spr(i))->clk5 == -16)
16277 {
16278 addEwpn(guys.spr(i)->x,guys.spr(i)->y,guys.spr(i)->z,wpn,3,wdp,dir,getUID(), 0, guys.spr(i)->fakez);
16279 sfx(wpnsfx(wpn),pan(int32_t(x)));
16280 }
16281 break;
16282 }
16283 default: //old behavior, all eyes can fire any time
16284 {
16285
3/8
✓ Branch 0 taken 145268 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1155 times.
✓ Branch 5 taken 1155 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
145268 if ((((dmisc18 && !(zc_oldrand() % zc_max(dmisc18, 1))) ||
16286
3/6
✓ Branch 0 taken 145268 times.
✓ Branch 1 taken 1155 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1155 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
147578 (!dmisc18 && !(zc_oldrand()&127))) && (((esPatra*)guys.spr(i))->clk5 >= 0 || !(editorflags & ENEMY_FLAG3) || !get_qr(qr_NEWENEMYTILES))
16287
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1155 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1155 && ((esPatra*)guys.spr(i))->clk5 >= dmisc19) && (!(editorflags & ENEMY_FLAG7) || (loopcnt == 0 &&
16288 (dmisc20 != 2 && (basesize*((int64_t)dmisc6 - (misc%dmisc6))) > 48))))
16289 {
16290
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1155 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1155 if ((editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES))
16291 {
16292 ((esPatra*)guys.spr(i))->clk5 = -48;
16293 if (editorflags & ENEMY_FLAG6) clk4 = 64;
16294 }
16295 else
16296 {
16297 1155 addEwpn(guys.spr(i)->x,guys.spr(i)->y,guys.spr(i)->z,wpn,3,wdp,dir,getUID(), 0, fakez);
16298 1155 sfx(wpnsfx(wpn),pan(int32_t(x)));
16299 1155 ((esPatra*)guys.spr(i))->clk5 = 0;
16300
1/2
✓ Branch 0 taken 1155 times.
✗ Branch 1 not taken.
1155 if (editorflags & ENEMY_FLAG6) clk4 = 16;
16301 }
16302 1155 }
16303
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 145268 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
147578 if ((editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES) && ((esPatra*)guys.spr(i))->clk5 == -16)
16304 {
16305 addEwpn(guys.spr(i)->x,guys.spr(i)->y,guys.spr(i)->z,wpn,3,wdp,dir,getUID(), 0, fakez);
16306 sfx(wpnsfx(wpn),pan(int32_t(x)));
16307 }
16308 145268 break;
16309 }
16310 }
16311 145268 }
16312 145268 }
16313
16314 }
16315 334429 }
16316 46240 }
16317
16318 160441 adjusted=true;
16319 160441 return enemy::animate(index);
16320 161885 }
16321
16322 249 void ePatra::FirePatraWeapon()
16323 { //.707
16324 249 int32_t xoff = 0;
16325 249 int32_t yoff = 0;
16326
1/2
✓ Branch 0 taken 249 times.
✗ Branch 1 not taken.
249 if ( SIZEflags&OVERRIDE_HIT_WIDTH )
16327 {
16328 xoff += (hit_width/2)-8;
16329 //Z_scripterrlog("width flag enabled. xoff = %d\n", xoff);
16330 }
16331
1/2
✓ Branch 0 taken 249 times.
✗ Branch 1 not taken.
249 if ( SIZEflags&OVERRIDE_HIT_HEIGHT )
16332 {
16333 yoff += (hit_height/2)-8;
16334 //Z_scripterrlog("width flag enabled. yoff = %d\n", yoff);
16335 }
16336 249 sfx(wpnsfx(wpn),pan(int32_t(x)));
16337
1/3
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 249 times.
249 switch (dmisc28)
16338 {
16339 case patrat8SHOT: //Fire Wizzrobe
16340 case patrat4SHOTDIAG:
16341 case patrat4SHOTRAND:
16342 if (dmisc28 != patrat4SHOTRAND || (zc_oldrand()%2)) //if it's the 4 shot rand type, only let it through half the time. Break is within so it doesn't do both, but if it skips this one it'll always do the other one.
16343 {
16344 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,1,wdp,l_up,-1, getUID(),false));
16345 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
16346 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
16347 if (wpn != ewFlame && wpn != ewFlame2) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step *= .707; //Fire already does this internall for asome bizarre reason.
16348
16349 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,1,wdp,l_down,-1, getUID(),false));
16350 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
16351 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
16352 if (wpn != ewFlame && wpn != ewFlame2) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step *= .707; //Fire already does this internall for asome bizarre reason.
16353
16354 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,1,wdp,r_up,-1, getUID(),false));
16355 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
16356 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
16357 if (wpn != ewFlame && wpn != ewFlame2) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step *= .707; //Fire already does this internall for asome bizarre reason.
16358
16359 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,1,wdp,r_down,-1, getUID(),false));
16360 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
16361 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
16362 if (wpn != ewFlame && wpn != ewFlame2) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step *= .707; //Fire already does this internall for asome bizarre reason.
16363
16364 if (dmisc28 == patrat4SHOTDIAG || dmisc28 == patrat4SHOTRAND) break;
16365 }
16366
16367 [[fallthrough]];
16368 case patrat4SHOTCARD: //Stalfos 3
16369 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,1,wdp,up,-1, getUID(),false));
16370 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
16371 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
16372 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,1,wdp,down,-1, getUID(),false));
16373 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
16374 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
16375 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,1,wdp,left,-1, getUID(),false));
16376 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
16377 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
16378 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,1,wdp,right,-1, getUID(),false));
16379 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
16380 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
16381 break;
16382
16383 default:
16384 249 addEwpn(x,y,z,wpn,3,wdp,dir,getUID(), 0, fakez);
16385
1/2
✓ Branch 0 taken 249 times.
✗ Branch 1 not taken.
249 if (dmisc28 == patratBREATH) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->angle += (zc_rand(20,-20)/100.0)*PI;
16386 249 double anglestore = ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->angle;
16387
3/6
✓ Branch 0 taken 249 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 249 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 249 times.
249 if (dmisc28 == patrat1SHOTFAST || dmisc28 == patrat3SHOTFAST || dmisc28 == patrat5SHOTFAST) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step *= 2;
16388
4/8
✓ Branch 0 taken 249 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 249 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 249 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 249 times.
249 if (dmisc28 == patrat3SHOT || dmisc28 == patrat3SHOTFAST || dmisc28 == patrat5SHOT || dmisc28 == patrat5SHOTFAST)
16389 {
16390 addEwpn(x,y,z,wpn,3,wdp,dir,getUID(), 0, fakez);
16391 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->angle = anglestore + (double)0.46364761;
16392 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step += 0.1180;
16393 if (dmisc28 == patrat3SHOTFAST || dmisc28 == patrat5SHOTFAST) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step *= 2;
16394 addEwpn(x,y,z,wpn,3,wdp,dir,getUID(), 0, fakez);
16395 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->angle = anglestore - (double)0.46364761;
16396 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step += 0.1180;
16397 if (dmisc28 == patrat3SHOTFAST || dmisc28 == patrat5SHOTFAST) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step *= 2;
16398 if (dmisc28 == patrat5SHOT || dmisc28 == patrat5SHOTFAST)
16399 {
16400 addEwpn(x,y,z,wpn,3,wdp,dir,getUID(), 0, fakez);
16401 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->angle = anglestore + (double)0.78539816;
16402 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step += 0.4142;
16403 if (dmisc28 == patrat5SHOTFAST) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step *= 2;
16404 addEwpn(x,y,z,wpn,3,wdp,dir,getUID(), 0, fakez);
16405 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->angle = anglestore - (double)0.78539816;
16406 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step += 0.4142;
16407 if (dmisc28 == patrat5SHOTFAST) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step *= 2;
16408 }
16409 }
16410 249 break;
16411
16412 }
16413 249 sfx(wpnsfx(wpn),pan(int32_t(x)));
16414 //+0.46364761
16415 //11.80
16416 249 }
16417
16418 324242 void ePatra::draw(BITMAP *dest)
16419 {
16420 324242 tile=o_tile;
16421 324242 update_enemy_frame();
16422 324242 enemy::draw(dest);
16423 324242 }
16424
16425 int32_t ePatra::defend(int32_t wpnId, int32_t *power, int32_t edef)
16426 {
16427 int32_t ret = enemy::defend(wpnId, power, edef);
16428
16429 if(ret < 0 && (flycnt||flycnt2))
16430 return 0;
16431
16432 return ret;
16433 }
16434
16435 1733 int32_t ePatra::defendNew(int32_t wpnId, int32_t *power, int32_t edef, byte unblockable)
16436 {
16437 1733 int32_t ret = enemy::defendNew(wpnId, power, edef, unblockable);
16438
16439
6/6
✓ Branch 0 taken 1613 times.
✓ Branch 1 taken 120 times.
✓ Branch 2 taken 779 times.
✓ Branch 3 taken 834 times.
✓ Branch 4 taken 447 times.
✓ Branch 5 taken 332 times.
1733 if(ret < 0 && (flycnt||flycnt2))
16440 1281 return 0;
16441
16442 452 return ret;
16443 1733 }
16444
16445 190 void ePatra::init_size_flags() {
16446 190 SIZEflags = d->SIZEflags;
16447
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 190 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
190 if (((SIZEflags & OVERRIDE_TILE_WIDTH) != 0) && txsz > 0) { txsz = txsz; if (txsz > 1) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
16448
1/2
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
190 else if (dmisc10 == 1) { txsz = 2; extend = 3; }
16449 // al_trace("Enemy txsz:%i\n", txsz);
16450
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 190 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
190 if (((SIZEflags & OVERRIDE_TILE_HEIGHT) != 0) && tysz > 0) { tysz = tysz; if (tysz > 1) extend = 3; }
16451
1/2
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
190 else if (dmisc10 == 1) { tysz = 2; extend = 3; }
16452
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 190 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
190 if (((SIZEflags & OVERRIDE_HIT_WIDTH) != 0) && hit_width >= 0) hit_width = hit_width;
16453
1/2
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
190 else if (dmisc10 == 1) hit_width = 32;
16454
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 190 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
190 if (((SIZEflags & OVERRIDE_HIT_HEIGHT) != 0) && hit_height >= 0) hit_height = hit_height;
16455
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 190 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
190 if (((SIZEflags & OVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0) hzsz = hzsz;
16456
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 190 times.
190 if ((SIZEflags & OVERRIDE_HIT_X_OFFSET) != 0) hxofs = hxofs;
16457
1/2
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
190 else if (dmisc10 == 1) hxofs = -8;
16458
1/2
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
190 if ((SIZEflags & OVERRIDE_HIT_Y_OFFSET) != 0) hyofs = hyofs;
16459 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
16460
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 190 times.
190 if ((SIZEflags & OVERRIDE_DRAW_X_OFFSET) != 0) xofs = (int32_t)xofs;
16461
1/2
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
190 else if (dmisc10 == 1) xofs = -8;
16462
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 190 times.
190 if ((SIZEflags & OVERRIDE_DRAW_Y_OFFSET) != 0)
16463 {
16464 yofs = (int32_t)yofs; //This seems to be setting to +48 or something with any value set?! -Z
16465 yofs += (get_qr(qr_OLD_DRAWOFFSET) ? playing_field_offset : original_playing_field_offset); //this offset fixes yofs not plaing properly. -Z
16466 }
16467
1/4
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
190 else if (dmisc10 == 1) yofs = (get_qr(qr_OLD_DRAWOFFSET) ? playing_field_offset : original_playing_field_offset) - 8;
16468
1/2
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
190 if (editorflags & ENEMY_FLAG8) misc = 1;
16469
16470
1/2
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
190 if ((SIZEflags & OVERRIDE_DRAW_Z_OFFSET) != 0) zofs = (int32_t)zofs;
16471
16472 190 }
16473
16474 3312 esPatra::esPatra(zfix X,zfix Y,int32_t Id,int32_t Clk, sprite * prnt) : enemy(X,Y,Id,Clk), parent(prnt)
16475 1656 {
16476 //cs=8;
16477 1656 item_set=0;
16478 1656 misc=clk;
16479 1656 clk4 = 0;
16480 1656 clk5 = 0;
16481 1656 clk = -((misc*21)>>1)-1;
16482
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1656 times.
✓ Branch 2 taken 1656 times.
✗ Branch 3 not taken.
1656 yofs=(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
16483 1656 hit_width=12;
16484 1656 hit_height=12;
16485 1656 hxofs=2;
16486 1656 hyofs=2;
16487 1656 extend = 0;
16488 1656 txsz = 1;
16489 1656 tysz = 1;
16490 /* //These need to be separate enemy editor fields. This enemy class also its draw altered to correctly support big stuff.
16491 enemy *prntenemy = (enemy *) guys.getByUID(parent->getUID());
16492 int32_t prntSIZEflags = prntenemy->SIZEflags;
16493 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = prntenemy->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
16494 // al_trace("Enemy txsz:%i\n", txsz);
16495 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = prntenemy->tysz; if ( tysz > 1 ) extend = 3; }
16496 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hxsz >= 0 ) hxsz = prntenemy->hxsz;
16497 else
16498 hxsz=12;
16499 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hysz >= 0 ) hysz = prntenemy->hysz;
16500 else
16501 hysz=12;
16502 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = prntenemy->hzsz;
16503 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = prntenemy->hxofs;
16504 else
16505 hxofs=2;
16506 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = prntenemy->hyofs;
16507 else hyofs=2;
16508 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
16509 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)prntenemy->xofs;
16510 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
16511 {
16512 yofs = (int32_t)prntenemy->yofs; //This seems to be setting to +48 or something with any value set?! -Z
16513 }
16514
16515 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)prntenemy->zofs;
16516 */
16517 1656 mainguy=count_enemy=false;
16518 1656 bgsfx=-1;
16519 //o_tile=0;
16520
2/4
✓ Branch 0 taken 1656 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1656 times.
✗ Branch 3 not taken.
1656 flags &= (~guy_never_return);
16521 1656 deadsfx = WAV_EDEAD;
16522 1656 hitsfx = WAV_EHIT;
16523 1656 isCore = false;
16524 1656 }
16525
16526 1010584 bool esPatra::animate(int32_t index)
16527 {
16528
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1010584 times.
1010584 if(switch_hooked) return enemy::animate(index);
16529
2/2
✓ Branch 0 taken 15160 times.
✓ Branch 1 taken 995424 times.
1010584 if(dying)
16530 15160 return Dead(index);
16531
16532 995424 return enemy::animate(index);
16533 1010584 }
16534
16535 2028196 void esPatra::draw(BITMAP *dest)
16536 {
16537
2/2
✓ Branch 0 taken 1721294 times.
✓ Branch 1 taken 306902 times.
2028196 if(get_qr(qr_NEWENEMYTILES))
16538 {
16539 1721294 tile = o_tile+(clk&3);
16540
16541
8/9
✓ Branch 0 taken 214278 times.
✓ Branch 1 taken 217924 times.
✓ Branch 2 taken 215346 times.
✓ Branch 3 taken 215726 times.
✓ Branch 4 taken 213062 times.
✓ Branch 5 taken 214350 times.
✓ Branch 6 taken 215734 times.
✓ Branch 7 taken 214874 times.
✗ Branch 8 not taken.
1721294 switch(dir) //directions get screwed up after 8. *shrug*
16542 {
16543 case up: //u
16544 214278 flip=0;
16545 214278 break;
16546
16547 case down: //d
16548 217924 flip=0;
16549 217924 tile+=4;
16550 217924 break;
16551
16552 case left: //l
16553 215346 flip=0;
16554 215346 tile+=8;
16555 215346 break;
16556
16557 case right: //r
16558 215726 flip=0;
16559 215726 tile+=12;
16560 215726 break;
16561
16562 case l_up: //ul
16563 213062 flip=0;
16564 213062 tile+=20;
16565 213062 break;
16566
16567 case r_up: //ur
16568 214350 flip=0;
16569 214350 tile+=24;
16570 214350 break;
16571
16572 case l_down: //dl
16573 215734 flip=0;
16574 215734 tile+=28;
16575 215734 break;
16576
16577 case r_down: //dr
16578 214874 flip=0;
16579 214874 tile+=32;
16580 214874 break;
16581 }
16582 1721294 }
16583 else
16584 {
16585 306902 tile = o_tile+((clk&2)>>1);
16586 }
16587
16588
2/2
✓ Branch 0 taken 114856 times.
✓ Branch 1 taken 1913340 times.
2028196 if(clk>=0)
16589 1913340 enemy::draw(dest);
16590 2028196 }
16591
16592
16593 102 ePatraBS::ePatraBS(zfix ,zfix ,int32_t Id,int32_t Clk) : enemy((zfix)128,(zfix)48,Id,Clk)
16594 102 {
16595 102 adjusted=false;
16596
1/2
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
102 dir=(zc_oldrand()&7)+8;
16597
1/2
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
102 step=0.25;
16598 102 clk4 = 0;
16599 102 clk5 = 0;
16600 //flycnt=6; flycnt2=0;
16601 102 flycnt=dmisc1;
16602 102 flycnt2=0; // PatraBS doesn't have inner rings!
16603 102 loopcnt=0;
16604
1/2
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
102 init_size_flags();
16605
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 102 times.
102 if(dmisc6<int16_t(1))dmisc6=1; // ratio cannot be 0!
16606
16607 //nets+4480;
16608 102 }
16609
16610 35963 bool ePatraBS::animate(int32_t index)
16611 {
16612
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 35963 times.
35963 if(switch_hooked) return enemy::animate(index);
16613
2/2
✓ Branch 0 taken 240 times.
✓ Branch 1 taken 35723 times.
35963 if(dying)
16614 240 return Dead(index);
16615
16616
2/2
✓ Branch 0 taken 31705 times.
✓ Branch 1 taken 4018 times.
35723 if(clk==0)
16617 {
16618 4018 removearmos(x,y,ffcactivated);
16619 4018 }
16620
16621 35723 variable_walk_8(rate,homing,hrate,spw_floater);
16622
16623
2/2
✓ Branch 0 taken 35387 times.
✓ Branch 1 taken 336 times.
35723 if(++clk2>90)
16624 {
16625 336 clk2=0;
16626
16627
2/2
✓ Branch 0 taken 177 times.
✓ Branch 1 taken 159 times.
336 if(loopcnt)
16628 177 --loopcnt;
16629 else
16630 {
16631
2/2
✓ Branch 0 taken 84 times.
✓ Branch 1 taken 75 times.
159 if((misc%dmisc6)==0)
16632 84 loopcnt=dmisc7;
16633 }
16634
16635 336 ++misc;
16636 336 }
16637
16638 // double size=1;;
16639
2/2
✓ Branch 0 taken 153472 times.
✓ Branch 1 taken 35723 times.
189195 for(int32_t i=index+1; i<index+flycnt+1; i++)
16640 {
16641
2/2
✓ Branch 0 taken 152860 times.
✓ Branch 1 taken 612 times.
153472 if(!adjusted)
16642 {
16643 612 ((enemy*)guys.spr(i))->hp=dmisc3;
16644
16645
1/2
✓ Branch 0 taken 612 times.
✗ Branch 1 not taken.
612 if(get_qr(qr_NEWENEMYTILES))
16646 {
16647 612 ((enemy*)guys.spr(i))->o_tile=o_tile+dmisc8;
16648 612 }
16649 else
16650 {
16651 ((enemy*)guys.spr(i))->o_tile=o_tile+1;
16652 }
16653
16654 612 ((enemy*)guys.spr(i))->cs = dmisc9;
16655 612 }
16656
16657
2/2
✓ Branch 0 taken 104 times.
✓ Branch 1 taken 153368 times.
153472 if(((enemy*)guys.spr(i))->hp <= 0)
16658 {
16659
2/2
✓ Branch 0 taken 131 times.
✓ Branch 1 taken 104 times.
235 for(int32_t j=i; j<index+flycnt+flycnt2; j++)
16660 {
16661 131 guys.swap(j,j+1);
16662 131 }
16663
16664 104 --flycnt;
16665 104 }
16666 else
16667 {
16668 153368 int32_t pos2 = ((enemy*)guys.spr(i))->misc;
16669
1/2
✓ Branch 0 taken 153368 times.
✗ Branch 1 not taken.
153368 double a2 = ((int64_t)clk2-pos2*90/(dmisc1==0?1:dmisc1))*PI/45;
16670 153368 temp_x = zc::math::Cos(a2+PI/2)*45;
16671 153368 temp_y = -zc::math::Sin(a2+PI/2)*45;
16672
16673
2/2
✓ Branch 0 taken 77643 times.
✓ Branch 1 taken 75725 times.
153368 if(loopcnt>0)
16674 {
16675 77643 guys.spr(i)->x = zc::math::Cos(a2+PI/2)*45;
16676
1/2
✓ Branch 0 taken 77643 times.
✗ Branch 1 not taken.
77643 guys.spr(i)->y = (-zc::math::Sin(a2+PI/2)-zc::math::Cos(pos2*PI*2/(dmisc1==0?1:dmisc1)))*22.5;
16677 77643 }
16678 else
16679 {
16680 75725 guys.spr(i)->x = temp_x;
16681 75725 guys.spr(i)->y = temp_y;
16682 }
16683
16684 double _MSVC2022_tmp1, _MSVC2022_tmp2;
16685 153368 double ddir=atan2_MSVC2022_FIX(double(temp_y),double(temp_x));
16686
16687
4/4
✓ Branch 0 taken 29178 times.
✓ Branch 1 taken 124190 times.
✓ Branch 2 taken 10366 times.
✓ Branch 3 taken 18812 times.
153368 if((ddir<=(((-5)*PI)/8))&&(ddir>(((-7)*PI)/8)))
16688 {
16689 18812 guys.spr(i)->dir=l_down;
16690 18812 }
16691
4/4
✓ Branch 0 taken 29205 times.
✓ Branch 1 taken 105351 times.
✓ Branch 2 taken 10366 times.
✓ Branch 3 taken 18839 times.
134556 else if((ddir<=(((-3)*PI)/8))&&(ddir>(((-5)*PI)/8)))
16692 {
16693 18839 guys.spr(i)->dir=left;
16694 18839 }
16695
4/4
✓ Branch 0 taken 29168 times.
✓ Branch 1 taken 86549 times.
✓ Branch 2 taken 10366 times.
✓ Branch 3 taken 18802 times.
115717 else if((ddir<=(((-1)*PI)/8))&&(ddir>(((-3)*PI)/8)))
16696 {
16697 18802 guys.spr(i)->dir=l_up;
16698 18802 }
16699
4/4
✓ Branch 0 taken 30509 times.
✓ Branch 1 taken 66406 times.
✓ Branch 2 taken 10366 times.
✓ Branch 3 taken 20143 times.
96915 else if((ddir<=(((1)*PI)/8))&&(ddir>(((-1)*PI)/8)))
16700 {
16701 20143 guys.spr(i)->dir=up;
16702 20143 }
16703
4/4
✓ Branch 0 taken 28883 times.
✓ Branch 1 taken 47889 times.
✓ Branch 2 taken 10366 times.
✓ Branch 3 taken 18517 times.
76772 else if((ddir<=(((3)*PI)/8))&&(ddir>(((1)*PI)/8)))
16704 {
16705 18517 guys.spr(i)->dir=r_up;
16706 18517 }
16707
4/4
✓ Branch 0 taken 29145 times.
✓ Branch 1 taken 29110 times.
✓ Branch 2 taken 10366 times.
✓ Branch 3 taken 18779 times.
58255 else if((ddir<=(((5)*PI)/8))&&(ddir>(((3)*PI)/8)))
16708 {
16709 18779 guys.spr(i)->dir=right;
16710 18779 }
16711
4/4
✓ Branch 0 taken 29358 times.
✓ Branch 1 taken 10118 times.
✓ Branch 2 taken 10366 times.
✓ Branch 3 taken 18992 times.
39476 else if((ddir<=(((7)*PI)/8))&&(ddir>(((5)*PI)/8)))
16712 {
16713 18992 guys.spr(i)->dir=r_down;
16714 18992 }
16715 else
16716 {
16717 20484 guys.spr(i)->dir=down;
16718 }
16719
16720 153368 guys.spr(i)->x += x;
16721 153368 guys.spr(i)->y += y;
16722 }
16723 153472 }
16724
16725 35723 adjusted=true;
16726 35723 return enemy::animate(index);
16727 35963 }
16728
16729 72874 void ePatraBS::draw(BITMAP *dest)
16730 {
16731 72874 tile=o_tile;
16732
16733
1/2
✓ Branch 0 taken 72874 times.
✗ Branch 1 not taken.
72874 if(get_qr(qr_NEWENEMYTILES))
16734 {
16735 double _MSVC2022_tmp1, _MSVC2022_tmp2;
16736 72874 double ddir=atan2_MSVC2022_FIX(double(y-(Hero.y)),double(Hero.x-x));
16737
16738
4/4
✓ Branch 0 taken 27164 times.
✓ Branch 1 taken 45710 times.
✓ Branch 2 taken 8018 times.
✓ Branch 3 taken 19146 times.
72874 if((ddir<=(((-5)*PI)/8))&&(ddir>(((-7)*PI)/8)))
16739 {
16740 19146 lookat=l_down;
16741 19146 }
16742
4/4
✓ Branch 0 taken 26316 times.
✓ Branch 1 taken 27412 times.
✓ Branch 2 taken 8018 times.
✓ Branch 3 taken 18298 times.
53728 else if((ddir<=(((-3)*PI)/8))&&(ddir>(((-5)*PI)/8)))
16743 {
16744 18298 lookat=down;
16745 18298 }
16746
4/4
✓ Branch 0 taken 21642 times.
✓ Branch 1 taken 13788 times.
✓ Branch 2 taken 8018 times.
✓ Branch 3 taken 13624 times.
35430 else if((ddir<=(((-1)*PI)/8))&&(ddir>(((-3)*PI)/8)))
16747 {
16748 13624 lookat=r_down;
16749 13624 }
16750
4/4
✓ Branch 0 taken 15510 times.
✓ Branch 1 taken 6296 times.
✓ Branch 2 taken 8018 times.
✓ Branch 3 taken 7492 times.
21806 else if((ddir<=(((1)*PI)/8))&&(ddir>(((-1)*PI)/8)))
16751 {
16752 7492 lookat=right;
16753 7492 }
16754
4/4
✓ Branch 0 taken 9188 times.
✓ Branch 1 taken 5126 times.
✓ Branch 2 taken 8018 times.
✓ Branch 3 taken 1170 times.
14314 else if((ddir<=(((3)*PI)/8))&&(ddir>(((1)*PI)/8)))
16755 {
16756 1170 lookat=r_up;
16757 1170 }
16758
4/4
✓ Branch 0 taken 8982 times.
✓ Branch 1 taken 4162 times.
✓ Branch 2 taken 8018 times.
✓ Branch 3 taken 964 times.
13144 else if((ddir<=(((5)*PI)/8))&&(ddir>(((3)*PI)/8)))
16759 {
16760 964 lookat=up;
16761 964 }
16762
4/4
✓ Branch 0 taken 9718 times.
✓ Branch 1 taken 2462 times.
✓ Branch 2 taken 1700 times.
✓ Branch 3 taken 8018 times.
12180 else if((ddir<=(((7)*PI)/8))&&(ddir>(((5)*PI)/8)))
16763 {
16764 1700 lookat=l_up;
16765 1700 }
16766 else
16767 {
16768 10480 lookat=left;
16769 }
16770
16771
8/9
✗ Branch 0 not taken.
✓ Branch 1 taken 964 times.
✓ Branch 2 taken 18298 times.
✓ Branch 3 taken 10480 times.
✓ Branch 4 taken 7492 times.
✓ Branch 5 taken 1700 times.
✓ Branch 6 taken 1170 times.
✓ Branch 7 taken 19146 times.
✓ Branch 8 taken 13624 times.
72874 switch(lookat) //directions get screwed up after 8. *shrug*
16772 {
16773 case up: //u
16774 964 flip=0;
16775 964 break;
16776
16777 case down: //d
16778 18298 flip=0;
16779 18298 tile+=8;
16780 18298 break;
16781
16782 case left: //l
16783 10480 flip=0;
16784 10480 tile+=40;
16785 10480 break;
16786
16787 case right: //r
16788 7492 flip=0;
16789 7492 tile+=48;
16790 7492 break;
16791
16792 case l_up: //ul
16793 1700 flip=0;
16794 1700 tile+=80;
16795 1700 break;
16796
16797 case r_up: //ur
16798 1170 flip=0;
16799 1170 tile+=88;
16800 1170 break;
16801
16802 case l_down: //dl
16803 19146 flip=0;
16804 19146 tile+=120;
16805 19146 break;
16806
16807 case r_down: //dr
16808 13624 flip=0;
16809 13624 tile+=128;
16810 13624 break;
16811 }
16812
16813 72874 tile+=(2*(clk&3));
16814 72874 xofs-=8;
16815 72874 yofs-=8;
16816 72874 drawblock(dest,15);
16817 72874 xofs+=8;
16818 72874 yofs+=8;
16819 72874 }
16820 else
16821 {
16822 flip=(clk&1);
16823 xofs-=8;
16824 yofs-=8;
16825 enemy::draw(dest);
16826 xofs+=16;
16827 enemy::draw(dest);
16828 yofs+=16;
16829 enemy::draw(dest);
16830 xofs-=16;
16831 enemy::draw(dest);
16832 xofs+=8;
16833 yofs-=8;
16834 }
16835 72874 }
16836
16837 int32_t ePatraBS::defend(int32_t wpnId, int32_t *power, int32_t edef)
16838 {
16839 int32_t ret = enemy::defend(wpnId, power, edef);
16840
16841 if(ret < 0 && (flycnt||flycnt2))
16842 return 0;
16843
16844 return ret;
16845 }
16846
16847 142 int32_t ePatraBS::defendNew(int32_t wpnId, int32_t *power, int32_t edef, byte unblockable)
16848 {
16849 142 int32_t ret = enemy::defendNew(wpnId, power, edef, unblockable);
16850
16851
5/6
✓ Branch 0 taken 141 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 60 times.
✓ Branch 3 taken 81 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 60 times.
142 if(ret < 0 && (flycnt||flycnt2))
16852 81 return 0;
16853
16854 61 return ret;
16855 142 }
16856
16857 102 void ePatraBS::init_size_flags()
16858 {
16859 102 SIZEflags = d->SIZEflags;
16860
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 102 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
102 if (((SIZEflags & OVERRIDE_TILE_WIDTH) != 0) && txsz > 0) { txsz = d->txsz; if (txsz > 1) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
16861 // al_trace("Enemy txsz:%i\n", txsz);
16862
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 102 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
102 if (((SIZEflags & OVERRIDE_TILE_HEIGHT) != 0) && tysz > 0) { tysz = d->tysz; if (tysz > 1) extend = 3; }
16863
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 102 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
102 if (((SIZEflags & OVERRIDE_HIT_WIDTH) != 0) && hit_width >= 0) hit_width = d->hxsz;
16864 102 else hit_width = 32;
16865
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 102 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
102 if (((SIZEflags & OVERRIDE_HIT_HEIGHT) != 0) && hit_height >= 0) hit_height = d->hysz;
16866
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 102 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
102 if (((SIZEflags & OVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0) hzsz = d->hzsz;
16867
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 102 times.
102 if ((SIZEflags & OVERRIDE_HIT_X_OFFSET) != 0) hxofs = d->hxofs;
16868 102 else hxofs = -8;
16869
1/2
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
102 if ((SIZEflags & OVERRIDE_HIT_Y_OFFSET) != 0) hyofs = d->hyofs;
16870 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
16871
1/2
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
102 if ((SIZEflags & OVERRIDE_DRAW_X_OFFSET) != 0) xofs = (int32_t)d->xofs;
16872
1/2
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
102 if ((SIZEflags & OVERRIDE_DRAW_Y_OFFSET) != 0)
16873 {
16874 yofs = (int32_t)d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
16875 yofs += (get_qr(qr_OLD_DRAWOFFSET) ? playing_field_offset : original_playing_field_offset); //this offset fixes yofs not plaing properly. -Z
16876 }
16877
16878
1/2
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
102 if ((SIZEflags & OVERRIDE_DRAW_Z_OFFSET) != 0) zofs = (int32_t)d->zofs;
16879 102 }
16880
16881 1224 esPatraBS::esPatraBS(zfix X,zfix Y,int32_t Id,int32_t Clk, sprite * prnt) : enemy(X,Y,Id,Clk), parent(prnt)
16882 612 {
16883 //cs=csBOSS;
16884 612 item_set=0;
16885 612 misc=clk;
16886 612 clk = -((misc*21)>>1)-1;
16887 612 clk4 = 0;
16888 612 clk5 = 0;
16889
2/4
✓ Branch 0 taken 612 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 612 times.
✗ Branch 3 not taken.
612 enemy *prntenemy = (enemy *) guys.getByUID(parent->getUID());
16890 612 int32_t prntSIZEflags = prntenemy->SIZEflags;
16891
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 612 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
612 if ( ((prntSIZEflags&OVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = prntenemy->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
16892 // al_trace("Enemy txsz:%i\n", txsz);
16893
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 612 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
612 if ( ((prntSIZEflags&OVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = prntenemy->tysz; if ( tysz > 1 ) extend = 3; }
16894
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 612 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
612 if ( ((prntSIZEflags&OVERRIDE_HIT_WIDTH) != 0) && hit_width >= 0 ) hit_width = prntenemy->hit_width;
16895 612 else hit_width=16;
16896
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 612 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
612 if ( ((prntSIZEflags&OVERRIDE_HIT_HEIGHT) != 0) && hit_height >= 0 ) hit_height = prntenemy->hit_height;
16897 612 else hit_height=16;
16898
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 612 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
612 if ( ((prntSIZEflags&OVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = prntenemy->hzsz;
16899
1/2
✓ Branch 0 taken 612 times.
✗ Branch 1 not taken.
612 if ( (prntSIZEflags&OVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = prntenemy->hxofs;
16900
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 612 times.
612 if ( (prntSIZEflags&OVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = prntenemy->hyofs;
16901 612 else hyofs=2;
16902 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
16903
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 612 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
612 if ( (prntSIZEflags&OVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)prntenemy->xofs;
16904
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 612 times.
612 if ( (prntSIZEflags&OVERRIDE_DRAW_Y_OFFSET) != 0 )
16905 {
16906 yofs = (int32_t)prntenemy->yofs;
16907 }
16908
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 612 times.
✓ Branch 2 taken 612 times.
✗ Branch 3 not taken.
612 else yofs=(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
16909
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 612 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
612 if ( (prntSIZEflags&OVERRIDE_DRAW_Z_OFFSET) != 0 ) prntenemy->zofs = (int32_t)zofs;
16910
16911 612 bgsfx=-1;
16912 612 mainguy=count_enemy=false;
16913 612 deadsfx = WAV_EDEAD;
16914 612 hitsfx = WAV_EHIT;
16915
2/4
✓ Branch 0 taken 612 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 612 times.
✗ Branch 3 not taken.
612 flags &= ~guy_never_return;
16916 612 isCore = false;
16917 612 }
16918
16919 155090 bool esPatraBS::animate(int32_t index)
16920 {
16921
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 155090 times.
155090 if(switch_hooked) return enemy::animate(index);
16922
2/2
✓ Branch 0 taken 1552 times.
✓ Branch 1 taken 153538 times.
155090 if(dying)
16923 1552 return Dead(index);
16924
16925 153538 return enemy::animate(index);
16926 155090 }
16927
16928 315868 void esPatraBS::draw(BITMAP *dest)
16929 {
16930 315868 tile=o_tile;
16931
16932
1/2
✓ Branch 0 taken 315868 times.
✗ Branch 1 not taken.
315868 if(get_qr(qr_NEWENEMYTILES))
16933 {
16934
8/9
✓ Branch 0 taken 41612 times.
✓ Branch 1 taken 42622 times.
✓ Branch 2 taken 37916 times.
✓ Branch 3 taken 38458 times.
✓ Branch 4 taken 38564 times.
✓ Branch 5 taken 38568 times.
✓ Branch 6 taken 38662 times.
✓ Branch 7 taken 39466 times.
✗ Branch 8 not taken.
315868 switch(dir) //directions get screwed up after 8. *shrug*
16935 {
16936 case up: //u
16937 41612 flip=0;
16938 41612 break;
16939
16940 case down: //d
16941 42622 flip=0;
16942 42622 tile+=4;
16943 42622 break;
16944
16945 case left: //l
16946 37916 flip=0;
16947 37916 tile+=8;
16948 37916 break;
16949
16950 case right: //r
16951 38458 flip=0;
16952 38458 tile+=12;
16953 38458 break;
16954
16955 case l_up: //ul
16956 38564 flip=0;
16957 38564 tile+=20;
16958 38564 break;
16959
16960 case r_up: //ur
16961 38568 flip=0;
16962 38568 tile+=24;
16963 38568 break;
16964
16965 case l_down: //dl
16966 38662 flip=0;
16967 38662 tile+=28;
16968 38662 break;
16969
16970 case r_down: //dr
16971 39466 flip=0;
16972 39466 tile+=32;
16973 39466 break;
16974 }
16975
16976 315868 tile += ((clk&6)>>1);
16977 315868 }
16978 else
16979 {
16980 tile += (clk&4)?1:0;
16981 }
16982
16983
2/2
✓ Branch 0 taken 32116 times.
✓ Branch 1 taken 283752 times.
315868 if(clk>=0)
16984 283752 enemy::draw(dest);
16985 315868 }
16986
16987 241822 void addEwpn(int32_t x,int32_t y,int32_t z,int32_t id,int32_t type,int32_t power,int32_t dir, int32_t parentid, byte script_generated, int32_t fakez)
16988 {
16989
4/6
✓ Branch 0 taken 135636 times.
✓ Branch 1 taken 106186 times.
✓ Branch 2 taken 135636 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 135636 times.
✗ Branch 5 not taken.
241822 if(id>wEnemyWeapons || (id >= wScript1 && id <= wScript10))
16990
4/8
✓ Branch 0 taken 241822 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 241822 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 241822 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 241822 times.
✗ Branch 7 not taken.
241822 Ewpns.add(new weapon((zfix)x,(zfix)y,(zfix)z,id,type,power,dir, -1, parentid, script_generated));
16991
1/2
✓ Branch 0 taken 241822 times.
✗ Branch 1 not taken.
241822 if (fakez > 0) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
16992 241822 }
16993
16994 74329 int32_t hit_enemy(int32_t index, int32_t wpnId,int32_t power,int32_t wpnx,int32_t wpny,int32_t dir, int32_t enemyHitWeapon, weapon* realweap)
16995 {
16996 // Kludge
16997
4/8
✓ Branch 0 taken 74329 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 74329 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 74329 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 74329 times.
✗ Branch 7 not taken.
74329 weapon *w = new weapon((zfix)wpnx,(zfix)wpny,(zfix)0,wpnId,0,power,dir,enemyHitWeapon,-1,false);
16998 74329 int32_t ret = ((enemy*)guys.spr(index))->takehit(w,realweap);
16999
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 74329 times.
74329 delete w;
17000 74329 return ret;
17001 }
17002
17003 9138 void enemy_scored(int32_t index)
17004 {
17005 9138 ((enemy*)guys.spr(index))->scored=true;
17006 9138 }
17007
17008 2178 void addguy(int32_t x,int32_t y,int32_t id,int32_t clk,bool mainguy,mapscr* parentscr)
17009 {
17010
6/10
✓ Branch 0 taken 2178 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2178 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2178 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 272 times.
✓ Branch 7 taken 1906 times.
✓ Branch 8 taken 2178 times.
✗ Branch 9 not taken.
2178 guy *g = new guy((zfix)x,(zfix)(y+(isdungeon()?1:0)),id,get_qr(qr_NOGUYPOOF)?0:clk,mainguy);
17011
5/6
✓ Branch 0 taken 1268 times.
✓ Branch 1 taken 910 times.
✓ Branch 2 taken 4 times.
✓ Branch 3 taken 1264 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 4 times.
2178 if(parentscr && parentscr->guytile > -1 && !get_qr(qr_OLD_GUY_HANDLING))
17012 {
17013 4 g->o_tile = parentscr->guytile;
17014
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(g->o_tile != 0)
17015 4 g->flags &= ~guy_invisible;
17016 4 g->cs = parentscr->guycs;
17017 4 }
17018 2178 guys.add(g);
17019 2178 }
17020
17021 23564 void additem(int32_t x,int32_t y,int32_t id,int32_t pickup)
17022 {
17023
4/8
✓ Branch 0 taken 23564 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 23564 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 23564 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 23564 times.
✗ Branch 7 not taken.
23564 item *i = new item(zfix(x), zfix(y - get_qr(qr_NOITEMOFFSET)), 0_zf, id, pickup, 0);
17024 23564 items.add(i);
17025 23564 }
17026
17027 150 void additem(int32_t x,int32_t y,int32_t id,int32_t pickup,int32_t clk)
17028 {
17029
5/10
✓ Branch 0 taken 150 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 150 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 150 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 150 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 150 times.
✗ Branch 9 not taken.
150 item *i = new item((zfix)x,(zfix)y-(get_qr(qr_NOITEMOFFSET)),(zfix)0,id,pickup,clk);
17030 150 items.add(i);
17031 150 }
17032
17033 3 void adddummyitem(int32_t x,int32_t y,int32_t id,int32_t pickup)
17034 {
17035
5/10
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 3 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 3 times.
✗ Branch 9 not taken.
3 item *i = new item((zfix)x,(zfix)y-(get_qr(qr_NOITEMOFFSET)),(zfix)0,id,pickup,0,true);
17036 3 items.add(i);
17037 3 }
17038
17039 96 void kill_em_all()
17040 {
17041
2/2
✓ Branch 0 taken 353 times.
✓ Branch 1 taken 96 times.
449 for(int32_t i=0; i<guys.Count(); i++)
17042 {
17043 353 enemy *e = ((enemy*)guys.spr(i));
17044
17045
3/6
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 323 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 30 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
353 if(e->flags&(1<<3) && !(e->family == eeGHINI && e->dmisc1 == 1)) continue;
17046
17047 323 e->kickbucket();
17048 323 }
17049 96 }
17050
17051 bool can_kill_em_all()
17052 {
17053 for(int32_t i=0; i<guys.Count(); i++)
17054 {
17055 enemy *e = ((enemy*)guys.spr(i));
17056
17057 if(e->flags&(1<<3) && !(e->family == eeGHINI && e->dmisc1 == 1)) continue;
17058 if(e->superman) continue;
17059 return true;
17060 }
17061 return false;
17062 }
17063
17064 //This needs a quest rule, or enemy flag, Dying Enemy Doesn't Hurt Hero
17065 // For Hero's hit detection. Don't count them if they are stunned or are guys.
17066 int32_t GuyHit(int32_t tx,int32_t ty,int32_t tz,int32_t txsz,int32_t tysz,int32_t tzsz)
17067 {
17068 for(int32_t i=0; i<guys.Count(); i++)
17069 {
17070 if(guys.spr(i)->hit(tx,ty,tz,txsz,tysz,tzsz))
17071 {
17072 if(((enemy*)guys.spr(i))->stunclk==0 && ((enemy*)guys.spr(i))->frozenclock==0 && (!get_qr(qr_SAFEENEMYFADE) || ((enemy*)guys.spr(i))->fading != fade_flicker)
17073 &&(((enemy*)guys.spr(i))->d->family != eeGUY || ((enemy*)guys.spr(i))->dmisc1))
17074 {
17075 return i;
17076 }
17077 }
17078 }
17079
17080 return -1;
17081 }
17082
17083 13007833 int32_t GuyHitFrom(int32_t index,int32_t tx,int32_t ty,int32_t tz,int32_t txsz,int32_t tysz,int32_t tzsz)
17084 {
17085
4/4
✓ Branch 0 taken 16502 times.
✓ Branch 1 taken 12991331 times.
✓ Branch 2 taken 33607435 times.
✓ Branch 3 taken 12977156 times.
46584591 for(int32_t i=zc_max(0, index); i<guys.Count(); i++)
17086 {
17087
2/2
✓ Branch 0 taken 30677 times.
✓ Branch 1 taken 33576758 times.
33607435 if(guys.spr(i)->hit(tx,ty,tz,txsz,tysz,tzsz))
17088 {
17089 30677 return i;
17090 }
17091 33576758 }
17092
17093 12977156 return -1;
17094 13007833 }
17095
17096 // For Hero's hit detection. Count them if they are dying.
17097 52199 int32_t GuyHit(int32_t index,int32_t tx,int32_t ty,int32_t tz,int32_t txsz,int32_t tysz,int32_t tzsz)
17098 {
17099 52199 enemy *e = (enemy*)guys.spr(index);
17100
3/4
✓ Branch 0 taken 52199 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 27828 times.
✓ Branch 3 taken 24371 times.
52199 if(!e || e->hp > 0)
17101 27828 return -1;
17102
17103 24371 bool d = e->dying;
17104 24371 int32_t hc = e->hclk;
17105 24371 e->dying = false;
17106 24371 e->hclk = 0;
17107 24371 bool hit = e->hit(tx,ty,tz,txsz,tysz,tzsz);
17108 24371 e->dying = d;
17109 24371 e->hclk = hc;
17110
17111
2/2
✓ Branch 0 taken 157 times.
✓ Branch 1 taken 24214 times.
24371 return hit ? index : -1;
17112 52199 }
17113
17114 14167991 bool hasMainGuy()
17115 {
17116
2/2
✓ Branch 0 taken 15393915 times.
✓ Branch 1 taken 5528880 times.
20922795 for(int32_t i=0; i<guys.Count(); i++)
17117 {
17118
2/2
✓ Branch 0 taken 8639111 times.
✓ Branch 1 taken 6754804 times.
15393915 if(((enemy*)guys.spr(i))->mainguy)
17119 {
17120 8639111 return true;
17121 }
17122 6754804 }
17123
17124 5528880 return false;
17125 14167991 }
17126
17127 138 void EatHero(int32_t index)
17128 {
17129 138 ((eStalfos*)guys.spr(index))->eathero();
17130 138 }
17131
17132 9 void GrabHero(int32_t index)
17133 {
17134 9 ((eWallM*)guys.spr(index))->grabhero();
17135 9 }
17136
17137 1338 bool CarryHero()
17138 {
17139
1/2
✓ Branch 0 taken 3933 times.
✗ Branch 1 not taken.
3933 for(int32_t i=0; i<guys.Count(); i++)
17140 {
17141
2/2
✓ Branch 0 taken 2090 times.
✓ Branch 1 taken 1843 times.
3933 if(((guy*)(guys.spr(i)))->family==eeWALLM)
17142 {
17143
2/2
✓ Branch 0 taken 1338 times.
✓ Branch 1 taken 505 times.
1843 if(((eWallM*)guys.spr(i))->hashero)
17144 {
17145 1338 Hero.x=guys.spr(i)->x;
17146 1338 Hero.y=guys.spr(i)->y;
17147 1338 return ((eWallM*)guys.spr(i))->misc > 0;
17148 }
17149 505 }
17150
17151 // Like Likes currently can't carry Hero.
17152 /*
17153 if(((guy*)(guys.spr(i)))->family==eeLIKE)
17154 {
17155 if(((eLikeLike*)guys.spr(i))->hashero)
17156 {
17157 Hero.x=guys.spr(i)->x;
17158 Hero.y=guys.spr(i)->y;
17159 return (true);
17160 }
17161 }*/
17162 2595 }
17163
17164 return false;
17165 1338 }
17166
17167 // Move item with guy
17168 void movefairy(zfix &x,zfix &y,int32_t misc)
17169 {
17170 int32_t i = guys.idFirst(eITEMFAIRY+0x1000*misc);
17171
17172 if(i!=-1)
17173 {
17174 x = guys.spr(i)->x;
17175 y = guys.spr(i)->y;
17176 }
17177 }
17178
17179 // Move guy with item (used by FFC scripts and hookshot-dragged fairies)
17180 void movefairy2(zfix x,zfix y,int32_t misc)
17181 {
17182 int32_t i = guys.idFirst(eITEMFAIRY+0x1000*misc);
17183
17184 if(i!=-1)
17185 {
17186 guys.spr(i)->x = x;
17187 guys.spr(i)->y = y;
17188 }
17189 }// Move item with guy
17190
17191 60438 void movefairynew(zfix &x,zfix &y, item const &itemfairy)
17192 {
17193 60438 enemy *fairy = (enemy *) guys.getByUID(itemfairy.fairyUID);
17194
17195
1/2
✓ Branch 0 taken 60438 times.
✗ Branch 1 not taken.
60438 if(fairy)
17196 {
17197 60438 x = fairy->x;
17198 60438 y = fairy->y;
17199 60438 }
17200 60438 }
17201
17202 // Move guy with item (used by FFC scripts and hookshot-dragged fairies)
17203 404 void movefairynew2(zfix x,zfix y, item const &itemfairy)
17204 {
17205 404 enemy *fairy = (enemy *) guys.getByUID(itemfairy.fairyUID);
17206
17207
1/2
✓ Branch 0 taken 404 times.
✗ Branch 1 not taken.
404 if(fairy)
17208 {
17209 404 fairy->x = x;
17210 404 fairy->y = y;
17211 404 }
17212 404 }
17213
17214 void killfairy(int32_t misc)
17215 {
17216 int32_t i = guys.idFirst(eITEMFAIRY+0x1000*misc);
17217 guys.del(i);
17218 }
17219
17220 217 int32_t getGuyIndex(const int32_t eid)
17221 {
17222
1/2
✓ Branch 0 taken 826 times.
✗ Branch 1 not taken.
826 for(word i = 0; i < guys.Count(); i++)
17223 {
17224
2/2
✓ Branch 0 taken 217 times.
✓ Branch 1 taken 609 times.
826 if(guys.spr(i)->getUID() == eid)
17225 217 return i;
17226 609 }
17227
17228 return -1;
17229 217 }
17230
17231 217 void killfairynew(item const &itemfairy)
17232 {
17233 217 enemy *fairy = (enemy *) guys.getByUID(itemfairy.fairyUID);
17234
1/2
✓ Branch 0 taken 217 times.
✗ Branch 1 not taken.
217 if (fairy != NULL) guys.del(getGuyIndex(itemfairy.fairyUID));
17235 217 }
17236
17237 //Should probably change this to return an 'enemy*', null on failure -Em
17238 21701 int32_t addenemy(int32_t x,int32_t y,int32_t id,int32_t clk)
17239 {
17240 21701 return addenemy(x,y,0,id,clk);
17241 }
17242
17243 1965 int32_t addchild(int32_t x,int32_t y,int32_t id,int32_t clk, int32_t parent_scriptUID)
17244 {
17245 1965 return addchild(x,y,0,id,clk, parent_scriptUID);
17246 }
17247
17248 1997 int32_t addchild(int32_t x,int32_t y,int32_t z,int32_t id,int32_t clk, int32_t parent_scriptUID)
17249 {
17250
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1997 times.
1997 if(id <= 0) return 0;
17251
17252 1997 int32_t ret = 0;
17253 1997 sprite *e=NULL;
17254 1997 al_trace("Adding child\n");
17255
17256
6/31
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 110 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 1865 times.
✓ Branch 10 taken 15 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✓ Branch 15 taken 1 times.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✓ Branch 21 taken 2 times.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✓ Branch 27 taken 4 times.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
1997 switch(guysbuf[id&0xFFF].family)
17257 {
17258 //Fixme: possible enemy memory leak. (minor)
17259 case eeWALK:
17260
3/6
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 110 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 110 times.
✗ Branch 5 not taken.
110 e = new eStalfos((zfix)x,(zfix)y,id,clk);
17261 110 break;
17262
17263 case eeLEV:
17264 e = new eLeever((zfix)x,(zfix)y,id,clk);
17265 break;
17266
17267 case eeTEK:
17268 e = new eTektite((zfix)x,(zfix)y,id,clk);
17269 break;
17270
17271 case eePEAHAT:
17272 e = new ePeahat((zfix)x,(zfix)y,id,clk);
17273 break;
17274
17275 case eeZORA:
17276 e = new eZora((zfix)x,(zfix)y,id,clk);
17277 break;
17278
17279 case eeGHINI:
17280 e = new eGhini((zfix)x,(zfix)y,id,clk);
17281 break;
17282
17283 case eeKEESE:
17284
3/6
✓ Branch 0 taken 1865 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1865 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1865 times.
✗ Branch 5 not taken.
1865 e = new eKeese((zfix)x,(zfix)y,id,clk);
17285 1865 break;
17286
17287 case eeWIZZ:
17288
3/6
✓ Branch 0 taken 15 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 15 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 15 times.
✗ Branch 5 not taken.
15 e = new eWizzrobe((zfix)x,(zfix)y,id,clk);
17289 15 break;
17290
17291 case eePROJECTILE:
17292 e = new eProjectile((zfix)x,(zfix)y,id,clk);
17293 break;
17294
17295 case eeWALLM:
17296 e = new eWallM((zfix)x,(zfix)y,id,clk);
17297 break;
17298
17299 case eeAQUA:
17300 e = new eAquamentus((zfix)x,(zfix)y,id,clk);
17301 break;
17302
17303 case eeMOLD:
17304 e = new eMoldorm((zfix)x,(zfix)y,id,zc_max(1,zc_min(254,guysbuf[id&0xFFF].attributes[0])));
17305 break;
17306
17307 case eeMANHAN:
17308
3/6
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
1 e = new eManhandla((zfix)x,(zfix)y,id,clk);
17309 1 break;
17310
17311 case eeGLEEOK:
17312 e = new eGleeok((zfix)x,(zfix)y,id,zc_max(1,zc_min(254,guysbuf[id&0xFFF].attributes[0])));
17313 break;
17314
17315 case eeGHOMA:
17316 e = new eGohma((zfix)x,(zfix)y,id,clk);
17317 break;
17318
17319 case eeLANM:
17320 e = new eLanmola((zfix)x,(zfix)y,id,zc_max(1,zc_min(253,guysbuf[id&0xFFF].attributes[0])));
17321 break;
17322
17323 case eeGANON:
17324 e = new eGanon((zfix)x,(zfix)y,id,clk);
17325 break;
17326
17327 case eeFAIRY:
17328 e = new eItemFairy((zfix)x,(zfix)y,id+0x1000*clk,clk);
17329 break;
17330
17331 case eeFIRE:
17332
3/6
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
2 e = new eFire((zfix)x,(zfix)y,id,clk);
17333 2 break;
17334
17335 case eeOTHER:
17336 e = new eOther((zfix)x,(zfix)y,id,clk);
17337 break;
17338
17339
17340 case eeSCRIPT01:
17341 case eeSCRIPT02:
17342 case eeSCRIPT03:
17343 case eeSCRIPT04:
17344 case eeSCRIPT05:
17345 case eeSCRIPT06:
17346 case eeSCRIPT07:
17347 case eeSCRIPT08:
17348 case eeSCRIPT09:
17349 case eeSCRIPT10:
17350 case eeSCRIPT11:
17351 case eeSCRIPT12:
17352 case eeSCRIPT13:
17353 case eeSCRIPT14:
17354 case eeSCRIPT15:
17355 case eeSCRIPT16:
17356 case eeSCRIPT17:
17357 case eeSCRIPT18:
17358 case eeSCRIPT19:
17359 case eeSCRIPT20:
17360 {
17361 if ( !get_qr(qr_SCRIPT_FRIENDLY_ENEMY_TYPES) )
17362 {
17363 e = new eScript((zfix)x,(zfix)y,id,clk);
17364 break;
17365 }
17366 else return 0;
17367 }
17368
17369 case eeFFRIENDLY01:
17370 case eeFFRIENDLY02:
17371 case eeFFRIENDLY03:
17372 case eeFFRIENDLY04:
17373 case eeFFRIENDLY05:
17374 case eeFFRIENDLY06:
17375 case eeFFRIENDLY07:
17376 case eeFFRIENDLY08:
17377 case eeFFRIENDLY09:
17378 case eeFFRIENDLY10:
17379 {
17380 if ( !get_qr(qr_SCRIPT_FRIENDLY_ENEMY_TYPES) )
17381 {
17382 e = new eFriendly((zfix)x,(zfix)y,id,clk); break;
17383 }
17384 else return 0;
17385
17386 }
17387
17388 case eeSPINTILE:
17389 e = new eSpinTile((zfix)x,(zfix)y,id,clk);
17390 break;
17391
17392 // and these enemies use the misc10/misc2 value
17393 case eeROCK:
17394 {
17395 switch(guysbuf[id&0xFFF].attributes[9])
17396 {
17397 case 1:
17398 e = new eBoulder((zfix)x,(zfix)y,id,clk);
17399 break;
17400
17401 case 0:
17402 default:
17403 e = new eRock((zfix)x,(zfix)y,id,clk);
17404 break;
17405 }
17406
17407 break;
17408 }
17409
17410 case eeTRAP:
17411 {
17412 switch(guysbuf[id&0xFFF].attributes[1])
17413 {
17414 case 1:
17415 e = new eTrap2((zfix)x,(zfix)y,id,clk);
17416 break;
17417
17418 case 0:
17419 default:
17420 e = new eTrap((zfix)x,(zfix)y,id,clk);
17421 break;
17422 }
17423
17424 break;
17425 }
17426
17427 case eeDONGO:
17428 {
17429 switch(guysbuf[id&0xFFF].attributes[9])
17430 {
17431 case 1:
17432 e = new eDodongo2((zfix)x,(zfix)y,id,clk);
17433 break;
17434
17435 case 0:
17436 default:
17437 e = new eDodongo((zfix)x,(zfix)y,id,clk);
17438 break;
17439 }
17440
17441 break;
17442 }
17443
17444 case eeDIG:
17445 {
17446
1/3
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
4 switch(guysbuf[id&0xFFF].attributes[9])
17447 {
17448 case 1:
17449 e = new eLilDig((zfix)x,(zfix)y,id,clk);
17450 break;
17451
17452 4 case 0:
17453 default:
17454
3/6
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4 times.
✗ Branch 5 not taken.
4 e = new eBigDig((zfix)x,(zfix)y,id,clk);
17455 4 break;
17456 }
17457
17458 4 break;
17459 }
17460
17461 case eePATRA:
17462 {
17463 switch(guysbuf[id&0xFFF].attributes[9])
17464 {
17465 case 1:
17466 if (get_qr(qr_HARDCODED_BS_PATRA))
17467 {
17468 e = new ePatraBS((zfix)x,(zfix)y,id,clk);
17469 break;
17470 }
17471 [[fallthrough]];
17472 case 0:
17473 default:
17474 e = new ePatra((zfix)x,(zfix)y,id,clk);
17475 break;
17476 }
17477
17478 break;
17479 }
17480
17481 case eeGUY:
17482 {
17483 switch(guysbuf[id&0xFFF].attributes[9])
17484 {
17485 case 1:
17486 e = new eTrigger((zfix)x,(zfix)y,id,clk);
17487 break;
17488
17489 case 0:
17490 default:
17491 e = new eNPC((zfix)x,(zfix)y,id,clk);
17492 break;
17493 }
17494
17495 break;
17496 }
17497
17498 case eeNONE:
17499 if(guysbuf[id&0xFFF].attributes[9] ==1)
17500 {
17501 e = new eTrigger((zfix)x,(zfix)y,id,clk);
17502 break;
17503 break;
17504 }
17505 [[fallthrough]];
17506 default:
17507
17508 return 0;
17509 }
17510
17511 1997 ret++; // Made one enemy.
17512
17513
3/4
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 1990 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7 times.
1997 if(z && canfall(id))
17514 {
17515 7 e->z = (zfix)z;
17516 7 }
17517
17518
2/2
✓ Branch 0 taken 1990 times.
✓ Branch 1 taken 7 times.
1997 ((enemy*)e)->ceiling = (z && canfall(id));
17519 1997 ((enemy*)e)->parent_script_UID = parent_scriptUID;
17520
17521
17522
1/2
✓ Branch 0 taken 1997 times.
✗ Branch 1 not taken.
1997 if(!guys.add(e))
17523 {
17524 return 0;
17525 }
17526
17527 // add segments of segmented enemies
17528 1997 int32_t c=0;
17529
17530
2/6
✓ Branch 0 taken 1996 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1997 switch(guysbuf[id&0xFFF].family)
17531 {
17532 case eeMOLD:
17533 {
17534 byte is=((enemy*)guys.spr(guys.Count()-1))->item_set;
17535 id &= 0xFFF;
17536
17537 for(int32_t i=0; i<zc_max(1,zc_min(254,guysbuf[id].attributes[0])); i++)
17538 {
17539 //christ this is messy -DD
17540 int32_t segclk = -i*((int32_t)(8.0/(zslongToFix(guysbuf[id&0xFFF].step*100))));
17541
17542 if(!guys.add(new esMoldorm((zfix)x,(zfix)y,id+0x1000,segclk)))
17543 {
17544 al_trace("Moldorm segment %d could not be created!\n",i+1);
17545
17546 for(int32_t j=0; j<i+1; j++)
17547 guys.del(guys.Count()-1);
17548
17549 return 0;
17550 }
17551
17552 if(i>0)
17553 ((enemy*)guys.spr(guys.Count()-1))->item_set=is;
17554
17555 ret++;
17556 }
17557
17558 break;
17559 }
17560
17561 case eeLANM:
17562 {
17563 id &= 0xFFF;
17564 int32_t shft = guysbuf[id].attributes[1];
17565 byte is=((enemy*)guys.spr(guys.Count()-1))->item_set;
17566
17567 if(!guys.add(new esLanmola((zfix)x,(zfix)y,id+0x1000,0)))
17568 {
17569 al_trace("Lanmola segment 1 could not be created!\n");
17570 guys.del(guys.Count()-1);
17571 return 0;
17572 }
17573
17574 ret++;
17575
17576 for(int32_t i=1; i<zc_max(1,zc_min(253,guysbuf[id&0xFFF].attributes[0])); i++)
17577 {
17578 if(!guys.add(new esLanmola((zfix)x,(zfix)y,id+0x2000,-(i<<shft))))
17579 {
17580 al_trace("Lanmola segment %d could not be created!\n",i+1);
17581
17582 for(int32_t j=0; j<i+1; j++)
17583 guys.del(guys.Count()-1);
17584
17585 return 0;
17586 }
17587
17588 ((enemy*)guys.spr(guys.Count()-1))->item_set=is;
17589 ret++;
17590 }
17591 }
17592 break;
17593
17594 case eeMANHAN:
17595 1 id &= 0xFFF;
17596
17597
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 1 times.
5 for(int32_t i=0; i<((!(guysbuf[id].attributes[1]))?4:8); i++)
17598 {
17599
4/8
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 4 times.
✗ Branch 7 not taken.
4 if(!guys.add(new esManhandla((zfix)x,(zfix)y,id+0x1000,i)))
17600 {
17601 al_trace("Manhandla head %d could not be created!\n",i+1);
17602
17603 for(int32_t j=0; j<i+1; j++)
17604 {
17605 guys.del(guys.Count()-1);
17606 }
17607
17608 return 0;
17609 }
17610
17611 4 ret++;
17612 4 ((enemy*)guys.spr(guys.Count()-1))->frate=guysbuf[id].attributes[0];
17613 4 }
17614
17615 1 break;
17616
17617 case eeGLEEOK:
17618 {
17619 id &= 0xFFF;
17620
17621 for(int32_t i=0; i<zc_max(1,zc_min(254,guysbuf[id&0xFFF].attributes[0])); i++)
17622 {
17623 if(!guys.add(new esGleeok((zfix)x,(zfix)y,id+0x1000,c, e)))
17624 {
17625 al_trace("Gleeok head %d could not be created!\n",i+1);
17626
17627 for(int32_t j=0; j<i+1; j++)
17628 {
17629 guys.del(guys.Count()-1);
17630 }
17631
17632 return false;
17633 }
17634
17635 c-=guysbuf[id].attributes[3];
17636 ret++;
17637 }
17638 }
17639 break;
17640
17641
17642 case eePATRA:
17643 {
17644 id &= 0xFFF;
17645 int32_t outeyes = 0;
17646
17647 for(int32_t i=0; i<zc_min(254,guysbuf[id&0xFFF].attributes[0]); i++)
17648 {
17649 if(!((guysbuf[id].attributes[9] &&get_qr(qr_HARDCODED_BS_PATRA))?guys.add(new esPatraBS((zfix)x,(zfix)y,id+0x1000,i,e)):guys.add(new esPatra((zfix)x,(zfix)y,id+0x1000,i,e))))
17650 {
17651 al_trace("Patra outer eye %d could not be created!\n",i+1);
17652
17653 for(int32_t j=0; j<i+1; j++)
17654 guys.del(guys.Count()-1);
17655
17656 return 0;
17657 }
17658 else
17659 outeyes++;
17660
17661 ret++;
17662 }
17663
17664 for(int32_t i=0; i<zc_min(254,guysbuf[id&0xFFF].attributes[1]); i++)
17665 {
17666 if(!guys.add(new esPatra((zfix)x,(zfix)y,id+0x1000,i,e)))
17667 {
17668 al_trace("Patra inner eye %d could not be created!\n",i+1);
17669
17670 for(int32_t j=0; j<i+1+zc_min(254,outeyes); j++)
17671 guys.del(guys.Count()-1);
17672
17673 return 0;
17674 }
17675
17676 ret++;
17677 }
17678
17679 break;
17680 }
17681 }
17682
17683 1997 return ret;
17684 1997 }
17685
17686 // Returns number of enemies/segments created
17687 101430 int32_t addenemy(int32_t x,int32_t y,int32_t z,int32_t id,int32_t clk)
17688 {
17689 101430 int32_t realid = id&0xFFF;
17690
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 101430 times.
101430 if( realid > MAXGUYS )
17691 {
17692 return 0;
17693 }
17694
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 101430 times.
101430 if(id <= 0) return 0;
17695
17696 101430 int32_t ret = 0;
17697 101430 sprite *e=NULL;
17698
17699
28/31
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 50004 times.
✓ Branch 4 taken 3942 times.
✓ Branch 5 taken 5196 times.
✓ Branch 6 taken 1825 times.
✓ Branch 7 taken 2765 times.
✓ Branch 8 taken 461 times.
✓ Branch 9 taken 11717 times.
✓ Branch 10 taken 5311 times.
✓ Branch 11 taken 4429 times.
✓ Branch 12 taken 998 times.
✓ Branch 13 taken 126 times.
✓ Branch 14 taken 618 times.
✓ Branch 15 taken 149 times.
✓ Branch 16 taken 168 times.
✓ Branch 17 taken 93 times.
✓ Branch 18 taken 420 times.
✓ Branch 19 taken 13 times.
✓ Branch 20 taken 730 times.
✓ Branch 21 taken 757 times.
✓ Branch 22 taken 7314 times.
✓ Branch 23 taken 94 times.
✓ Branch 24 taken 384 times.
✓ Branch 25 taken 2432 times.
✓ Branch 26 taken 251 times.
✓ Branch 27 taken 403 times.
✓ Branch 28 taken 292 times.
✓ Branch 29 taken 5 times.
✓ Branch 30 taken 533 times.
101430 switch(guysbuf[id&0xFFF].family)
17700 {
17701 //Fixme: possible enemy memory leak. (minor)
17702 case eeWALK:
17703
3/6
✓ Branch 0 taken 50004 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 50004 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 50004 times.
✗ Branch 5 not taken.
50004 e = new eStalfos((zfix)x,(zfix)y,id,clk);
17704 50004 break;
17705
17706 case eeLEV:
17707
3/6
✓ Branch 0 taken 3942 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3942 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3942 times.
✗ Branch 5 not taken.
3942 e = new eLeever((zfix)x,(zfix)y,id,clk);
17708 3942 break;
17709
17710 case eeTEK:
17711
3/6
✓ Branch 0 taken 5196 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5196 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 5196 times.
✗ Branch 5 not taken.
5196 e = new eTektite((zfix)x,(zfix)y,id,clk);
17712 5196 break;
17713
17714 case eePEAHAT:
17715
3/6
✓ Branch 0 taken 1825 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1825 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1825 times.
✗ Branch 5 not taken.
1825 e = new ePeahat((zfix)x,(zfix)y,id,clk);
17716 1825 break;
17717
17718 case eeZORA:
17719
3/6
✓ Branch 0 taken 2765 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2765 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2765 times.
✗ Branch 5 not taken.
2765 e = new eZora((zfix)x,(zfix)y,id,clk);
17720 2765 break;
17721
17722 case eeGHINI:
17723
3/6
✓ Branch 0 taken 461 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 461 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 461 times.
✗ Branch 5 not taken.
461 e = new eGhini((zfix)x,(zfix)y,id,clk);
17724 461 break;
17725
17726 case eeKEESE:
17727
3/6
✓ Branch 0 taken 11717 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 11717 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 11717 times.
✗ Branch 5 not taken.
11717 e = new eKeese((zfix)x,(zfix)y,id,clk);
17728 11717 break;
17729
17730 case eeWIZZ:
17731
3/6
✓ Branch 0 taken 5311 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5311 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 5311 times.
✗ Branch 5 not taken.
5311 e = new eWizzrobe((zfix)x,(zfix)y,id,clk);
17732 5311 break;
17733
17734 case eePROJECTILE:
17735
3/6
✓ Branch 0 taken 4429 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4429 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4429 times.
✗ Branch 5 not taken.
4429 e = new eProjectile((zfix)x,(zfix)y,id,clk);
17736 4429 break;
17737
17738 case eeWALLM:
17739
3/6
✓ Branch 0 taken 998 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 998 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 998 times.
✗ Branch 5 not taken.
998 e = new eWallM((zfix)x,(zfix)y,id,clk);
17740 998 break;
17741
17742 case eeAQUA:
17743
3/6
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 126 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 126 times.
✗ Branch 5 not taken.
126 e = new eAquamentus((zfix)x,(zfix)y,id,clk);
17744 126 break;
17745
17746 case eeMOLD:
17747
6/12
✓ Branch 0 taken 618 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 618 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 618 times.
✓ Branch 6 taken 618 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 618 times.
✓ Branch 10 taken 618 times.
✗ Branch 11 not taken.
618 e = new eMoldorm((zfix)x,(zfix)y,id,zc_max(1,zc_min(254,guysbuf[id&0xFFF].attributes[0])));
17748 618 break;
17749
17750 case eeMANHAN:
17751
3/6
✓ Branch 0 taken 149 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 149 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 149 times.
✗ Branch 5 not taken.
149 e = new eManhandla((zfix)x,(zfix)y,id,clk);
17752 149 break;
17753
17754 case eeGLEEOK:
17755
7/12
✓ Branch 0 taken 168 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 168 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 168 times.
✓ Branch 6 taken 152 times.
✓ Branch 7 taken 16 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 152 times.
✓ Branch 10 taken 168 times.
✗ Branch 11 not taken.
168 e = new eGleeok((zfix)x,(zfix)y,id,zc_max(1,zc_min(254,guysbuf[id&0xFFF].attributes[0])));
17756 168 break;
17757
17758 case eeGHOMA:
17759
3/6
✓ Branch 0 taken 93 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 93 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 93 times.
✗ Branch 5 not taken.
93 e = new eGohma((zfix)x,(zfix)y,id,clk);
17760 93 break;
17761
17762 case eeLANM:
17763
6/12
✓ Branch 0 taken 420 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 420 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 420 times.
✓ Branch 6 taken 420 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 420 times.
✓ Branch 10 taken 420 times.
✗ Branch 11 not taken.
420 e = new eLanmola((zfix)x,(zfix)y,id,zc_max(1,zc_min(253,guysbuf[id&0xFFF].attributes[0])));
17764 420 break;
17765
17766 case eeGANON:
17767
3/6
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 13 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 13 times.
✗ Branch 5 not taken.
13 e = new eGanon((zfix)x,(zfix)y,id,clk);
17768 13 break;
17769
17770 case eeFAIRY:
17771
3/6
✓ Branch 0 taken 730 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 730 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 730 times.
✗ Branch 5 not taken.
730 e = new eItemFairy((zfix)x,(zfix)y,id+0x1000*clk,clk);
17772 730 break;
17773
17774 case eeFIRE:
17775
3/6
✓ Branch 0 taken 757 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 757 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 757 times.
✗ Branch 5 not taken.
757 e = new eFire((zfix)x,(zfix)y,id,clk);
17776 757 break;
17777
17778 case eeOTHER:
17779
3/6
✓ Branch 0 taken 7314 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7314 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 7314 times.
✗ Branch 5 not taken.
7314 e = new eOther((zfix)x,(zfix)y,id,clk);
17780 7314 break;
17781
17782
17783 case eeSCRIPT01:
17784 case eeSCRIPT02:
17785 case eeSCRIPT03:
17786 case eeSCRIPT04:
17787 case eeSCRIPT05:
17788 case eeSCRIPT06:
17789 case eeSCRIPT07:
17790 case eeSCRIPT08:
17791 case eeSCRIPT09:
17792 case eeSCRIPT10:
17793 case eeSCRIPT11:
17794 case eeSCRIPT12:
17795 case eeSCRIPT13:
17796 case eeSCRIPT14:
17797 case eeSCRIPT15:
17798 case eeSCRIPT16:
17799 case eeSCRIPT17:
17800 case eeSCRIPT18:
17801 case eeSCRIPT19:
17802 case eeSCRIPT20:
17803 {
17804 if ( !get_qr(qr_SCRIPT_FRIENDLY_ENEMY_TYPES) )
17805 {
17806 e = new eScript((zfix)x,(zfix)y,id,clk);
17807 break;
17808 }
17809 else return 0;
17810 }
17811
17812 case eeFFRIENDLY01:
17813 case eeFFRIENDLY02:
17814 case eeFFRIENDLY03:
17815 case eeFFRIENDLY04:
17816 case eeFFRIENDLY05:
17817 case eeFFRIENDLY06:
17818 case eeFFRIENDLY07:
17819 case eeFFRIENDLY08:
17820 case eeFFRIENDLY09:
17821 case eeFFRIENDLY10:
17822 {
17823 if ( !get_qr(qr_SCRIPT_FRIENDLY_ENEMY_TYPES) )
17824 {
17825 e = new eFriendly((zfix)x,(zfix)y,id,clk); break;
17826 }
17827 else return 0;
17828
17829 }
17830
17831 case eeSPINTILE:
17832
3/6
✓ Branch 0 taken 94 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 94 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 94 times.
✗ Branch 5 not taken.
94 e = new eSpinTile((zfix)x,(zfix)y,id,clk);
17833 94 break;
17834
17835 // and these enemies use the misc10/misc2 value
17836 case eeROCK:
17837 {
17838
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
✓ Branch 2 taken 354 times.
384 switch(guysbuf[id&0xFFF].attributes[9])
17839 {
17840 case 1:
17841
3/6
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 30 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 30 times.
✗ Branch 5 not taken.
30 e = new eBoulder((zfix)x,(zfix)y,id,clk);
17842 30 break;
17843
17844 354 case 0:
17845 default:
17846
3/6
✓ Branch 0 taken 354 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 354 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 354 times.
✗ Branch 5 not taken.
354 e = new eRock((zfix)x,(zfix)y,id,clk);
17847 354 break;
17848 }
17849
17850 384 break;
17851 }
17852
17853 case eeTRAP:
17854 {
17855
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 832 times.
✓ Branch 2 taken 1600 times.
2432 switch(guysbuf[id&0xFFF].attributes[1])
17856 {
17857 case 1:
17858
3/6
✓ Branch 0 taken 832 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 832 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 832 times.
✗ Branch 5 not taken.
832 e = new eTrap2((zfix)x,(zfix)y,id,clk);
17859 832 break;
17860
17861 1600 case 0:
17862 default:
17863
3/6
✓ Branch 0 taken 1600 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1600 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1600 times.
✗ Branch 5 not taken.
1600 e = new eTrap((zfix)x,(zfix)y,id,clk);
17864 1600 break;
17865 }
17866
17867 2432 break;
17868 }
17869
17870 case eeDONGO:
17871 {
17872
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 48 times.
✓ Branch 2 taken 203 times.
251 switch(guysbuf[id&0xFFF].attributes[9])
17873 {
17874 case 1:
17875
3/6
✓ Branch 0 taken 48 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 48 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 48 times.
✗ Branch 5 not taken.
48 e = new eDodongo2((zfix)x,(zfix)y,id,clk);
17876 48 break;
17877
17878 203 case 0:
17879 default:
17880
3/6
✓ Branch 0 taken 203 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 203 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 203 times.
✗ Branch 5 not taken.
203 e = new eDodongo((zfix)x,(zfix)y,id,clk);
17881 203 break;
17882 }
17883
17884 251 break;
17885 }
17886
17887 case eeDIG:
17888 {
17889
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 327 times.
✓ Branch 2 taken 76 times.
403 switch(guysbuf[id&0xFFF].attributes[9])
17890 {
17891 case 1:
17892
3/6
✓ Branch 0 taken 327 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 327 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 327 times.
✗ Branch 5 not taken.
327 e = new eLilDig((zfix)x,(zfix)y,id,clk);
17893 327 break;
17894
17895 76 case 0:
17896 default:
17897
3/6
✓ Branch 0 taken 76 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 76 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 76 times.
✗ Branch 5 not taken.
76 e = new eBigDig((zfix)x,(zfix)y,id,clk);
17898 76 break;
17899 }
17900
17901 403 break;
17902 }
17903
17904 case eePATRA:
17905 {
17906
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 190 times.
✓ Branch 2 taken 102 times.
292 switch(guysbuf[id&0xFFF].attributes[9])
17907 {
17908 case 1:
17909
1/2
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
102 if (get_qr(qr_HARDCODED_BS_PATRA))
17910 {
17911
3/6
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 102 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 102 times.
✗ Branch 5 not taken.
102 e = new ePatraBS((zfix)x,(zfix)y,id,clk);
17912 102 break;
17913 }
17914 [[fallthrough]];
17915 190 case 0:
17916 default:
17917
3/6
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 190 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 190 times.
✗ Branch 5 not taken.
190 e = new ePatra((zfix)x,(zfix)y,id,clk);
17918 190 break;
17919 }
17920
17921 292 break;
17922 }
17923
17924 case eeGUY:
17925 {
17926
1/3
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
5 switch(guysbuf[id&0xFFF].attributes[9])
17927 {
17928 case 1:
17929 e = new eTrigger((zfix)x,(zfix)y,id,clk);
17930 break;
17931
17932 5 case 0:
17933 default:
17934
3/6
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 5 times.
✗ Branch 5 not taken.
5 e = new eNPC((zfix)x,(zfix)y,id,clk);
17935 5 break;
17936 }
17937
17938 5 break;
17939 }
17940
17941 case eeNONE:
17942
1/2
✓ Branch 0 taken 533 times.
✗ Branch 1 not taken.
533 if(guysbuf[id&0xFFF].attributes[9] ==1)
17943 {
17944
3/6
✓ Branch 0 taken 533 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 533 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 533 times.
✗ Branch 5 not taken.
533 e = new eTrigger((zfix)x,(zfix)y,id,clk);
17945 533 break;
17946 break;
17947 }
17948 [[fallthrough]];
17949 default:
17950
17951 return 0;
17952 }
17953
17954 101430 ret++; // Made one enemy.
17955
17956
4/4
✓ Branch 0 taken 131 times.
✓ Branch 1 taken 101299 times.
✓ Branch 2 taken 25 times.
✓ Branch 3 taken 106 times.
101430 if(z && canfall(id))
17957 {
17958 106 e->z = (zfix)z;
17959 106 }
17960
17961
2/2
✓ Branch 0 taken 101299 times.
✓ Branch 1 taken 131 times.
101430 ((enemy*)e)->ceiling = (z && canfall(id));
17962
17963
1/2
✓ Branch 0 taken 101430 times.
✗ Branch 1 not taken.
101430 if(!guys.add(e))
17964 {
17965 return 0;
17966 }
17967
17968 // add segments of segmented enemies
17969 101430 int32_t c=0;
17970
17971
6/6
✓ Branch 0 taken 99783 times.
✓ Branch 1 taken 618 times.
✓ Branch 2 taken 420 times.
✓ Branch 3 taken 149 times.
✓ Branch 4 taken 168 times.
✓ Branch 5 taken 292 times.
101430 switch(guysbuf[id&0xFFF].family)
17972 {
17973 case eeMOLD:
17974 {
17975 618 byte is=((enemy*)guys.spr(guys.Count()-1))->item_set;
17976 618 id &= 0xFFF;
17977
17978
5/8
✗ Branch 0 not taken.
✓ Branch 1 taken 3768 times.
✓ Branch 2 taken 3768 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 3768 times.
✓ Branch 6 taken 3150 times.
✓ Branch 7 taken 618 times.
3768 for(int32_t i=0; i<zc_max(1,zc_min(254,guysbuf[id].attributes[0])); i++)
17979 {
17980 //christ this is messy -DD
17981 3150 int32_t segclk = -i*((int32_t)(8.0/(zslongToFix(guysbuf[id&0xFFF].step*100))));
17982
17983
4/8
✓ Branch 0 taken 3150 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3150 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3150 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 3150 times.
✗ Branch 7 not taken.
3150 if(!guys.add(new esMoldorm((zfix)x,(zfix)y,id+0x1000,segclk)))
17984 {
17985 al_trace("Moldorm segment %d could not be created!\n",i+1);
17986
17987 for(int32_t j=0; j<i+1; j++)
17988 guys.del(guys.Count()-1);
17989
17990 return 0;
17991 }
17992
17993
2/2
✓ Branch 0 taken 618 times.
✓ Branch 1 taken 2532 times.
3150 if(i>0)
17994 2532 ((enemy*)guys.spr(guys.Count()-1))->item_set=is;
17995
17996 3150 ret++;
17997 3150 }
17998
17999 618 break;
18000 }
18001
18002 case eeLANM:
18003 {
18004 420 id &= 0xFFF;
18005 420 int32_t shft = guysbuf[id].attributes[1];
18006 420 byte is=((enemy*)guys.spr(guys.Count()-1))->item_set;
18007
18008
4/8
✓ Branch 0 taken 420 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 420 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 420 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 420 times.
✗ Branch 7 not taken.
420 if(!guys.add(new esLanmola((zfix)x,(zfix)y,id+0x1000,0)))
18009 {
18010 al_trace("Lanmola segment 1 could not be created!\n");
18011 guys.del(guys.Count()-1);
18012 return 0;
18013 }
18014
18015 420 ret++;
18016
18017
5/8
✗ Branch 0 not taken.
✓ Branch 1 taken 2267 times.
✓ Branch 2 taken 2267 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2267 times.
✓ Branch 6 taken 1847 times.
✓ Branch 7 taken 420 times.
2267 for(int32_t i=1; i<zc_max(1,zc_min(253,guysbuf[id&0xFFF].attributes[0])); i++)
18018 {
18019
4/8
✓ Branch 0 taken 1847 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1847 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1847 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1847 times.
✗ Branch 7 not taken.
1847 if(!guys.add(new esLanmola((zfix)x,(zfix)y,id+0x2000,-(i<<shft))))
18020 {
18021 al_trace("Lanmola segment %d could not be created!\n",i+1);
18022
18023 for(int32_t j=0; j<i+1; j++)
18024 guys.del(guys.Count()-1);
18025
18026 return 0;
18027 }
18028
18029 1847 ((enemy*)guys.spr(guys.Count()-1))->item_set=is;
18030 1847 ret++;
18031 1847 }
18032 }
18033 420 break;
18034
18035 case eeMANHAN:
18036 149 id &= 0xFFF;
18037
18038
2/2
✓ Branch 0 taken 688 times.
✓ Branch 1 taken 149 times.
837 for(int32_t i=0; i<((!(guysbuf[id].attributes[1]))?4:8); i++)
18039 {
18040
4/8
✓ Branch 0 taken 688 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 688 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 688 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 688 times.
✗ Branch 7 not taken.
688 if(!guys.add(new esManhandla((zfix)x,(zfix)y,id+0x1000,i)))
18041 {
18042 al_trace("Manhandla head %d could not be created!\n",i+1);
18043
18044 for(int32_t j=0; j<i+1; j++)
18045 {
18046 guys.del(guys.Count()-1);
18047 }
18048
18049 return 0;
18050 }
18051
18052 688 ret++;
18053 688 ((enemy*)guys.spr(guys.Count()-1))->frate=guysbuf[id].attributes[0];
18054 688 }
18055
18056 149 break;
18057
18058 case eeGLEEOK:
18059 {
18060 168 id &= 0xFFF;
18061 168 eGleeok* parent = (eGleeok*)e;
18062
18063
6/8
✗ Branch 0 not taken.
✓ Branch 1 taken 701 times.
✓ Branch 2 taken 669 times.
✓ Branch 3 taken 32 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 669 times.
✓ Branch 6 taken 533 times.
✓ Branch 7 taken 168 times.
701 for(int32_t i=0; i<zc_max(1,zc_min(254,guysbuf[id&0xFFF].attributes[0])); i++)
18064 {
18065
3/6
✓ Branch 0 taken 533 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 533 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 533 times.
✗ Branch 5 not taken.
533 esGleeok* head = new esGleeok((zfix)x,(zfix)y,id+0x1000,c, e);
18066
1/2
✓ Branch 0 taken 533 times.
✗ Branch 1 not taken.
533 if(!guys.add(head))
18067 {
18068 al_trace("Gleeok head %d could not be created!\n",i+1);
18069
18070 for(int32_t j=0; j<i+1; j++)
18071 {
18072 guys.del(guys.Count()-1);
18073 }
18074
18075 return false;
18076 }
18077
18078 533 head->necktile=parent->necktile;
18079 533 head->dummy_int[1]=parent->necktile;
18080
2/2
✓ Branch 0 taken 421 times.
✓ Branch 1 taken 112 times.
533 if(get_qr(qr_NEWENEMYTILES))
18081 {
18082 421 head->dummy_int[2]=parent->o_tile+parent->dmisc8; //connected head tile
18083 421 head->dummy_int[3]=parent->o_tile+parent->dmisc9; //flying head tile
18084 421 }
18085 else
18086 {
18087 112 head->dummy_int[2]=parent->necktile+1; //connected head tile
18088 112 head->dummy_int[3]=parent->necktile+2; //flying head tile
18089 }
18090 533 head->tile = head->dummy_int[2];
18091
18092 533 c-=guysbuf[id].attributes[3];
18093 533 ret++;
18094 533 }
18095 }
18096 168 break;
18097
18098
18099 case eePATRA:
18100 {
18101 292 id &= 0xFFF;
18102 292 int32_t outeyes = 0;
18103
18104
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2248 times.
✓ Branch 2 taken 1956 times.
✓ Branch 3 taken 292 times.
2248 for(int32_t i=0; i<zc_min(254,guysbuf[id&0xFFF].attributes[0]); i++)
18105 {
18106
10/22
✓ Branch 0 taken 612 times.
✓ Branch 1 taken 1344 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 612 times.
✓ Branch 4 taken 612 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 612 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 612 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 1344 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 1344 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 1344 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 1344 times.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
1956 if(!((guysbuf[id].attributes[9] &&get_qr(qr_HARDCODED_BS_PATRA))?guys.add(new esPatraBS((zfix)x,(zfix)y,id+0x1000,i,e)):guys.add(new esPatra((zfix)x,(zfix)y,id+0x1000,i,e))))
18107 {
18108 al_trace("Patra outer eye %d could not be created!\n",i+1);
18109
18110 for(int32_t j=0; j<i+1; j++)
18111 guys.del(guys.Count()-1);
18112
18113 return 0;
18114 }
18115 else
18116 1956 outeyes++;
18117
18118 1956 ret++;
18119 1956 }
18120
18121
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 604 times.
✓ Branch 2 taken 312 times.
✓ Branch 3 taken 292 times.
604 for(int32_t i=0; i<zc_min(254,guysbuf[id&0xFFF].attributes[1]); i++)
18122 {
18123
4/8
✓ Branch 0 taken 312 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 312 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 312 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 312 times.
✗ Branch 7 not taken.
312 if(!guys.add(new esPatra((zfix)x,(zfix)y,id+0x1000,i,e)))
18124 {
18125 al_trace("Patra inner eye %d could not be created!\n",i+1);
18126
18127 for(int32_t j=0; j<i+1+zc_min(254,outeyes); j++)
18128 guys.del(guys.Count()-1);
18129
18130 return 0;
18131 }
18132
18133 312 ret++;
18134 312 }
18135
18136 292 break;
18137 }
18138 }
18139
18140 101430 return ret;
18141 101430 }
18142
18143 1852748 bool isjumper(int32_t id)
18144 {
18145
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1852748 times.
1852748 if( ((unsigned)(id&0xFFF)) > MAXGUYS )
18146 {
18147 return false;
18148 }
18149
3/3
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 1750545 times.
✓ Branch 2 taken 102194 times.
1852748 switch(guysbuf[id&0xFFF].family)
18150 {
18151 case eeROCK:
18152 case eeTEK:
18153 9 return true;
18154
18155 case eeWALK:
18156
3/4
✓ Branch 0 taken 102194 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12265 times.
✓ Branch 3 taken 89929 times.
102194 if(guysbuf[id&0xFFF].attributes[8] == e9tVIRE || guysbuf[id & 0xFFF].attributes[8] == e9tPOLSVOICE) return true;
18157 89929 }
18158
18159 1840474 return false;
18160 1852748 }
18161
18162
18163 291817 bool isfixedtogrid(int32_t id)
18164 {
18165
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 291817 times.
291817 if( ((unsigned)(id&0xFFF)) > MAXGUYS )
18166 {
18167 return false;
18168 }
18169
1/2
✓ Branch 0 taken 291817 times.
✗ Branch 1 not taken.
291817 switch(guysbuf[id&0xFFF].family)
18170 {
18171 case eeWALK:
18172 case eeLEV:
18173 case eeZORA:
18174 case eeDONGO:
18175 case eeGANON:
18176 case eeROCK:
18177 case eeGLEEOK:
18178 case eeAQUA:
18179 case eeLANM:
18180 return true;
18181 }
18182
18183 291817 return false;
18184 291817 }
18185
18186 // Can't fall, can have Z value.
18187 51778511 bool isflier(int32_t id)
18188 {
18189
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 51778511 times.
51778511 if( ((unsigned)(id&0xFFF)) > MAXGUYS )
18190 {
18191 return false;
18192 }
18193
2/2
✓ Branch 0 taken 45350654 times.
✓ Branch 1 taken 6427857 times.
51778511 switch(guysbuf[id&0xFFF].family) //id&0x0FFF)
18194 {
18195 case eePEAHAT:
18196 case eeKEESE:
18197 case eePATRA:
18198 case eeFAIRY:
18199 case eeGHINI:
18200
18201 // Could theoretically have their Z set by a script
18202 case eeFIRE:
18203 6427857 return true;
18204 break;
18205 }
18206
18207 45350654 return false;
18208 51778511 }
18209
18210 // Can't have Z position
18211 3711290 bool never_in_air(int32_t id)
18212 {
18213
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3711290 times.
3711290 if( ((unsigned)(id&0xFFF)) > MAXGUYS )
18214 {
18215 return false;
18216 }
18217
2/2
✓ Branch 0 taken 3701740 times.
✓ Branch 1 taken 9550 times.
3711290 switch(guysbuf[id&0xFFF].family)
18218 {
18219 case eeMANHAN:
18220 case eeMOLD:
18221 case eeLANM:
18222 case eeGLEEOK:
18223 case eeZORA:
18224 case eeLEV:
18225 case eeAQUA:
18226 case eeROCK:
18227 case eeGANON:
18228 case eeTRAP:
18229 case eePROJECTILE:
18230 case eeSPINTILE:
18231 9550 return true;
18232 }
18233
18234 3701740 return false;
18235 3711290 }
18236
18237 2013509 bool canfall(int32_t id)
18238 {
18239
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2013509 times.
2013509 if( ((unsigned)(id&0xFFF)) > MAXGUYS )
18240 {
18241 return false;
18242 }
18243
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 2013469 times.
✓ Branch 2 taken 40 times.
2013509 switch(guysbuf[id&0xFFF].family)
18244 {
18245 case eeGUY:
18246 {
18247
1/2
✓ Branch 0 taken 40 times.
✗ Branch 1 not taken.
40 if(id < eOCTO1S)
18248 40 return false;
18249
18250 switch(guysbuf[id&0xFFF].attributes[9])
18251 {
18252 case 1:
18253 case 2:
18254 return true;
18255
18256 case 0:
18257 case 3:
18258 default:
18259 return false;
18260 }
18261
18262 case eeGHOMA:
18263 case eeDIG:
18264 return false;
18265 }
18266 }
18267
18268
18269
4/4
✓ Branch 0 taken 2005033 times.
✓ Branch 1 taken 8436 times.
✓ Branch 2 taken 152285 times.
✓ Branch 3 taken 1852748 times.
2013469 return !never_in_air(id) && !isflier(id) && !isjumper(id);
18270 2013509 }
18271
18272 73536095 bool enemy::enemycanfall(int32_t id, bool checkgrav)
18273 {
18274
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 73536095 times.
73536095 if( ((unsigned)(id&0xFFF)) > MAXGUYS )
18275 {
18276 return false;
18277 }
18278 //Z_scripterrlog("canfall family is %d:\n", family);
18279 //Z_scripterrlog("canfall gravity is %s:\n", moveflags & move_obeys_grav ? "true" : "false");
18280 //if ( family == eeFIRE && id >= eSTART )
18281 //{
18282 // Z_scripterrlog("eeFire\n");
18283 // return moveflags & move_obeys_grav; //'Other' enemy class, used by scripts. -Z
18284 //}
18285
18286 //In ZQ, eeFIRE is Other(floating) and eeOTHER is 'other'.
18287
18288
3/3
✓ Branch 0 taken 428935 times.
✓ Branch 1 taken 71040465 times.
✓ Branch 2 taken 2066695 times.
73536095 switch(guysbuf[id&0xFFF].family)
18289 {
18290 case eeGUY:
18291 {
18292
1/2
✓ Branch 0 taken 2066695 times.
✗ Branch 1 not taken.
2066695 if(id < eOCTO1S) //screen guys and fires that aren't real enemies, and never fall
18293 2066695 return false;
18294
18295 switch(guysbuf[id&0xFFF].attributes[9]) //I'm unsure what these specify off-hand. Needs better comments. -Z
18296 {
18297 case 1:
18298 case 2:
18299 return true;
18300
18301 case 0:
18302 case 3:
18303 default:
18304 return false;
18305 }
18306
18307 case eeGHOMA:
18308 case eeDIG:
18309 428935 return false;
18310 }
18311 }
18312
18313
2/2
✓ Branch 0 taken 38945357 times.
✓ Branch 1 taken 32095108 times.
71040465 if(!checkgrav) return true;
18314 38945357 return (moveflags & move_obeys_grav);
18315
18316 // if ( isflier(id) || isjumper(id) || never_in_air(id) )
18317 // {
18318 // if ( moveflags & move_obeys_grav ) return true;
18319 // else return false;
18320 // }
18321 // else
18322 // {
18323 // return (moveflags & move_obeys_grav);
18324 // }
18325 //return !never_in_air(id) && !isflier(id) && !isjumper(id);
18326 73536095 }
18327
18328 1266 void addfires()
18329 {
18330
2/2
✓ Branch 0 taken 811 times.
✓ Branch 1 taken 455 times.
1266 if(!get_qr(qr_NOGUYFIRES))
18331 {
18332 455 int32_t bs = get_qr(qr_BSZELDA);
18333 455 addguy(bs? 64: 72,64,gFIRE,-17,false,nullptr);
18334 455 addguy(bs?176:168,64,gFIRE,-18,false,nullptr);
18335 455 }
18336 1266 }
18337
18338 35208 void loadguys()
18339 {
18340
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 35208 times.
35208 if(loaded_guys)
18341 return;
18342
18343 35208 loaded_guys=true;
18344
18345 35208 byte Guy=0;
18346 // When in caves/item rooms, use mSPECIALITEM and ipONETIME2
18347 // Else use mITEM and ipONETIME
18348 35208 int32_t mf = (currscr>=128) ? mSPECIALITEM : mITEM;
18349 35208 int32_t onetime = (currscr>=128) ? ipONETIME2 : ipONETIME;
18350
18351 35208 repaircharge=0;
18352 35208 adjustmagic=false;
18353 35208 learnslash=false;
18354
18355
2/2
✓ Branch 0 taken 105624 times.
✓ Branch 1 taken 35208 times.
140832 for(int32_t i=0; i<3; i++)
18356 {
18357 105624 prices[i]=0;
18358 105624 }
18359
18360 35208 hasitem=0;
18361
18362 35208 mapscr* guyscr = tmpscr;
18363
4/4
✓ Branch 0 taken 904 times.
✓ Branch 1 taken 34304 times.
✓ Branch 2 taken 475 times.
✓ Branch 3 taken 429 times.
35208 if(currscr>=128 && DMaps[currdmap].flags&dmfGUYCAVES)
18364 {
18365
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 429 times.
429 if(DMaps[currdmap].flags&dmfCAVES)
18366 {
18367 429 Guy=tmpscr[1].guy;
18368 429 guyscr = tmpscr+1;
18369 429 }
18370 429 }
18371 else
18372 {
18373 34779 Guy=tmpscr->guy;
18374
18375
4/4
✓ Branch 0 taken 34304 times.
✓ Branch 1 taken 475 times.
✓ Branch 2 taken 24137 times.
✓ Branch 3 taken 10167 times.
34779 if(currscr < 0x80 && (DMaps[currdmap].flags&dmfVIEWMAP))
18376 10167 game->maps[(currmap*MAPSCRSNORMAL)+currscr] |= mVISITED; // mark as visited
18377 }
18378
18379 35208 bool oldguy = get_qr(qr_OLD_GUY_HANDLING);
18380 // The Guy appears if 'Hero is in cave' equals 'Guy is in cave'.
18381
4/4
✓ Branch 0 taken 3844 times.
✓ Branch 1 taken 31364 times.
✓ Branch 2 taken 2538 times.
✓ Branch 3 taken 1306 times.
35208 if(Guy && ((currscr>=128) == !!(DMaps[currdmap].flags&dmfGUYCAVES)))
18382 {
18383
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 1295 times.
1306 if(tmpscr->room==rZELDA)
18384 {
18385 11 addguy(120,72,Guy,-15,true,guyscr);
18386 11 guys.spr(0)->hxofs=1000;
18387 11 addenemy(128,96,eFIRE,-15);
18388 11 addenemy(112,96,eFIRE,-15);
18389 11 addenemy(96,120,eFIRE,-15);
18390 11 addenemy(144,120,eFIRE,-15);
18391 11 return;
18392 }
18393
18394
2/2
✓ Branch 0 taken 1291 times.
✓ Branch 1 taken 4 times.
2586 bool ffire = oldguy
18395
2/2
✓ Branch 0 taken 1266 times.
✓ Branch 1 taken 25 times.
1291 ? (Guy!=gFAIRY || !get_qr(qr_NOFAIRYGUYFIRES))
18396 4 : (guyscr->roomflags&RFL_GUYFIRES);
18397
2/2
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 1266 times.
1295 if(ffire)
18398 1266 addfires();
18399
18400
2/2
✓ Branch 0 taken 872 times.
✓ Branch 1 taken 423 times.
1295 if(currscr>=128)
18401
3/4
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 410 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 13 times.
436 if(getmapflag() && !(tmpscr->flags9&fBELOWRETURN))
18402 13 Guy=0;
18403
18404
4/6
✓ Branch 0 taken 166 times.
✓ Branch 1 taken 1083 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✓ Branch 5 taken 45 times.
1295 switch(tmpscr->room)
18405 {
18406 case rSP_ITEM:
18407 case rGRUMBLE:
18408 case rBOMBS:
18409 case rARROWS:
18410 case rSWINDLE:
18411 case rMUPGRADE:
18412 case rLEARNSLASH:
18413 case rTAKEONE:
18414
8/8
✓ Branch 0 taken 104 times.
✓ Branch 1 taken 62 times.
✓ Branch 2 taken 55 times.
✓ Branch 3 taken 49 times.
✓ Branch 4 taken 62 times.
✓ Branch 5 taken 49 times.
✓ Branch 6 taken 21 times.
✓ Branch 7 taken 41 times.
166 if((get_qr(qr_ITEMPICKUPSETSBELOW) && getmapflag((currscr < 128) ? mITEM : mSPECIALITEM)) || (!get_qr(qr_ITEMPICKUPSETSBELOW) && getmapflag() && !(tmpscr->flags9&fBELOWRETURN))) //get_qr(qr_ITEMPICKUPSETSBELOW)
18415 55 Guy=0;
18416
18417 166 break;
18418
18419 case rREPAIR:
18420 if (get_qr(qr_OLD_DOORREPAIR)) break;
18421 if((get_qr(qr_ITEMPICKUPSETSBELOW) && getmapflag((currscr < 128) ? mITEM : mSPECIALITEM)) || (!get_qr(qr_ITEMPICKUPSETSBELOW) && getmapflag() && !(tmpscr->flags9&fBELOWRETURN))) //get_qr(qr_ITEMPICKUPSETSBELOW)
18422 Guy=0;
18423
18424 break;
18425 case rRP_HC:
18426 if (get_qr(qr_OLD_POTION_OR_HC)) break;
18427 if((get_qr(qr_ITEMPICKUPSETSBELOW) && getmapflag((currscr < 128) ? mITEM : mSPECIALITEM)) || (!get_qr(qr_ITEMPICKUPSETSBELOW) && getmapflag() && !(tmpscr->flags9&fBELOWRETURN))) //get_qr(qr_ITEMPICKUPSETSBELOW)
18428 Guy=0;
18429
18430 break;
18431 case rMONEY:
18432
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if (get_qr(qr_OLD_SECRETMONEY)) break;
18433 if((get_qr(qr_ITEMPICKUPSETSBELOW) && getmapflag((currscr < 128) ? mITEM : mSPECIALITEM)) || (!get_qr(qr_ITEMPICKUPSETSBELOW) && getmapflag() && !(tmpscr->flags9&fBELOWRETURN))) //get_qr(qr_ITEMPICKUPSETSBELOW)
18434 Guy=0;
18435
18436 break;
18437
18438 case rTRIFORCE:
18439 {
18440 45 int32_t tc = TriforceCount();
18441
18442
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 34 times.
45 if(get_qr(qr_4TRI))
18443 {
18444
4/4
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 1 times.
11 if((get_qr(qr_3TRI) && tc>=3) || tc>=4)
18445 10 Guy=0;
18446 9 }
18447 else
18448 {
18449
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 34 times.
✓ Branch 2 taken 33 times.
✓ Branch 3 taken 1 times.
34 if((get_qr(qr_3TRI) && tc>=6) || tc>=8)
18450 33 Guy=0;
18451 }
18452 }
18453 43 break;
18454 }
18455
18456
2/2
✓ Branch 0 taken 107 times.
✓ Branch 1 taken 1186 times.
1293 if(Guy)
18457 {
18458
2/2
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 1157 times.
1186 if(ffire)
18459 1157 blockpath=true;
18460
18461
2/2
✓ Branch 0 taken 410 times.
✓ Branch 1 taken 776 times.
1186 if(currscr<128)
18462 776 sfx(WAV_SCALE);
18463
18464
4/4
✓ Branch 0 taken 459 times.
✓ Branch 1 taken 727 times.
✓ Branch 2 taken 104 times.
✓ Branch 3 taken 355 times.
1186 addguy(120,64,Guy, (dlevel||BSZ)?-15:startguy[zc_oldrand()&7], true,guyscr);
18465 1186 Hero.Freeze();
18466 1186 }
18467 1293 }
18468
5/6
✓ Branch 0 taken 32113 times.
✓ Branch 1 taken 1789 times.
✓ Branch 2 taken 71 times.
✓ Branch 3 taken 32042 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1789 times.
33902 else if(oldguy ? Guy==gFAIRY : (Guy && (guyscr->roomflags&RFL_ALWAYS_GUY))) // The only Guy that somewhat ignores the "Guys In Caves Only" DMap flag
18469 {
18470 71 sfx(WAV_SCALE);
18471 71 addguy(120,62,Guy,-14,false,guyscr);
18472 71 }
18473
18474 35195 loaditem();
18475
18476 // Collecting a rupee in a '10 Rupees' screen sets the mITEM screen state if
18477 // it doesn't appear in a Cave/Item Cellar, and the mSPECIALITEM screen state if it does.
18478
4/4
✓ Branch 0 taken 19 times.
✓ Branch 1 taken 35176 times.
✓ Branch 2 taken 4 times.
✓ Branch 3 taken 15 times.
35195 if(tmpscr->room==r10RUPIES && !getmapflag(mf))
18479 {
18480 //setmapflag();
18481
2/2
✓ Branch 0 taken 150 times.
✓ Branch 1 taken 15 times.
165 for(int32_t i=0; i<10; i++)
18482 150 additem(ten_rupies_x[i],ten_rupies_y[i],0,ipBIGRANGE+onetime,-14);
18483 15 }
18484 35206 }
18485
18486 35214 void loaditem()
18487 {
18488 35214 byte Item = 0;
18489
18490
2/2
✓ Branch 0 taken 34310 times.
✓ Branch 1 taken 904 times.
35214 if(currscr<128)
18491 {
18492 34310 Item=tmpscr->item;
18493
18494
4/4
✓ Branch 0 taken 1579 times.
✓ Branch 1 taken 32731 times.
✓ Branch 2 taken 31285 times.
✓ Branch 3 taken 3025 times.
34310 if((!getmapflag(mITEM) || (tmpscr->flags9&fITEMRETURN)) && (tmpscr->hasitem != 0))
18495 {
18496
2/2
✓ Branch 0 taken 59 times.
✓ Branch 1 taken 2966 times.
3025 if(tmpscr->flags8&fSECRETITEM)
18497 59 hasitem=8;
18498
2/2
✓ Branch 0 taken 1157 times.
✓ Branch 1 taken 1809 times.
2966 else if(tmpscr->flags&fITEM)
18499 1157 hasitem=1;
18500
2/2
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 1745 times.
1809 else if(tmpscr->enemyflags&efCARRYITEM)
18501 64 hasitem=4; // Will be set to 2 by roaming_item
18502 else
18503
2/4
✓ Branch 0 taken 1745 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1745 times.
✗ Branch 3 not taken.
3490 items.add(new item((zfix)tmpscr->itemx,
18504
6/12
✓ Branch 0 taken 15 times.
✓ Branch 1 taken 1730 times.
✓ Branch 2 taken 15 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 15 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✓ Branch 8 taken 1745 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 1745 times.
✗ Branch 11 not taken.
1745 (tmpscr->flags7&fITEMFALLS && isSideViewGravity()) ? (zfix)-170 : (zfix)tmpscr->itemy+(get_qr(qr_NOITEMOFFSET)?0:1),
18505
6/10
✓ Branch 0 taken 15 times.
✓ Branch 1 taken 1730 times.
✓ Branch 2 taken 15 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 15 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 15 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1730 times.
✗ Branch 9 not taken.
1745 (tmpscr->flags7&fITEMFALLS && !(isSideViewGravity())) ? (zfix)170 : (zfix)0,
18506
2/2
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 1640 times.
1745 Item,ipONETIME|ipBIGRANGE|((itemsbuf[Item].family==itype_triforcepiece ||
18507 1745 (tmpscr->flags3&fHOLDITEM)) ? ipHOLDUP : 0) | ((tmpscr->flags8&fITEMSECRET) ? ipSECRETS : 0),0));
18508 3025 }
18509 34310 }
18510
2/2
✓ Branch 0 taken 429 times.
✓ Branch 1 taken 475 times.
904 else if(!(DMaps[currdmap].flags&dmfCAVES))
18511 {
18512
4/6
✓ Branch 0 taken 475 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 469 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 16 times.
491 if((!getmapflag((currscr < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM) || (tmpscr[1].flags9&fBELOWRETURN)) && tmpscr[1].room==rSP_ITEM
18513
4/4
✓ Branch 0 taken 163 times.
✓ Branch 1 taken 312 times.
✓ Branch 2 taken 16 times.
✓ Branch 3 taken 147 times.
475 && (currscr==128 || !get_qr(qr_ITEMSINPASSAGEWAYS)))
18514 {
18515 163 Item=tmpscr[1].catchall;
18516
18517
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 162 times.
163 if(Item)
18518
2/4
✓ Branch 0 taken 162 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 162 times.
✗ Branch 3 not taken.
324 items.add(new item((zfix)tmpscr->itemx,
18519
3/12
✗ Branch 0 not taken.
✓ Branch 1 taken 162 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✓ Branch 8 taken 162 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 162 times.
✗ Branch 11 not taken.
162 (tmpscr->flags7&fITEMFALLS && isSideViewGravity()) ? (zfix)-170 : (zfix)tmpscr->itemy+(get_qr(qr_NOITEMOFFSET)?0:1),
18520
2/10
✗ Branch 0 not taken.
✓ Branch 1 taken 162 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✓ Branch 8 taken 162 times.
✗ Branch 9 not taken.
162 (tmpscr->flags7&fITEMFALLS && !(isSideViewGravity())) ? (zfix)170 : (zfix)0,
18521 162 Item,ipONETIME2|ipBIGRANGE|ipHOLDUP | ((tmpscr->flags8&fITEMSECRET) ? ipSECRETS : 0),0));
18522 163 }
18523 475 }
18524 35214 }
18525
18526 957 void never_return(int32_t index)
18527 {
18528
2/2
✓ Branch 0 taken 766 times.
✓ Branch 1 taken 191 times.
957 if(!get_qr(qr_KILLALL))
18529 191 goto doit;
18530
18531
2/2
✓ Branch 0 taken 2292 times.
✓ Branch 1 taken 329 times.
2621 for(int32_t i=0; i<guys.Count(); i++)
18532
4/4
✓ Branch 0 taken 980 times.
✓ Branch 1 taken 1312 times.
✓ Branch 2 taken 543 times.
✓ Branch 3 taken 437 times.
2292 if(((((enemy*)guys.spr(i))->d->flags)&guy_never_return) && i!=index)
18533 {
18534 437 goto dontdoit;
18535 329 }
18536
18537 doit:
18538 520 setmapflag(mNEVERRET);
18539 dontdoit:
18540 957 return;
18541 }
18542
18543 63436 bool slowguy(int32_t id)
18544 {
18545
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 63436 times.
63436 if( ((unsigned)(id&0xFFF)) > MAXGUYS )
18546 {
18547 return false;
18548 }
18549 //return (guysbuf[id].step<100);
18550
2/2
✓ Branch 0 taken 53852 times.
✓ Branch 1 taken 9584 times.
63436 switch(id)
18551 {
18552 case eOCTO1S:
18553 case eOCTO2S:
18554 case eOCTO1F:
18555 case eOCTO2F:
18556 case eLEV1:
18557 case eLEV2:
18558 case eROCK:
18559 case eBOULDER:
18560 9584 return true;
18561 }
18562
18563 53852 return false;
18564 63436 }
18565
18566 82771 bool ok2add(int32_t id)
18567 {
18568
2/4
✓ Branch 0 taken 82771 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 82771 times.
82771 if( ((unsigned)(id&0xFFF)) > MAXGUYS || id <= 0)
18569 {
18570 return false;
18571 }
18572
4/4
✓ Branch 0 taken 829 times.
✓ Branch 1 taken 81942 times.
✓ Branch 2 taken 464 times.
✓ Branch 3 taken 365 times.
82771 if(getmapflag(mNEVERRET) && (guysbuf[id].flags & guy_never_return))
18573 464 return false;
18574
18575
4/4
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 81666 times.
✓ Branch 2 taken 376 times.
✓ Branch 3 taken 201 times.
82307 switch(guysbuf[id].family)
18576 {
18577 // I added a special case for shooters because having traps on the same screen
18578 // was preventing them from spawning due to TMPNORET. This means they will
18579 // never stay dead, though, so it may not be the best solution. - Saf
18580 case eePROJECTILE:
18581 376 return true;
18582
18583
18584 case eeDIG:
18585 {
18586
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 126 times.
✓ Branch 2 taken 75 times.
201 switch(guysbuf[id].attributes[9])
18587 {
18588 case 1:
18589
2/2
✓ Branch 0 taken 79 times.
✓ Branch 1 taken 47 times.
126 if(!get_qr(qr_NOTMPNORET))
18590 79 return !getmapflag(mTMPNORET);
18591
18592 47 return true;
18593
18594 75 case 0:
18595 default:
18596 75 return true;
18597 }
18598 }
18599 case eeGANON:
18600 case eeTRAP:
18601
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 64 times.
128 if ((guysbuf[id].family == eeGANON && !get_qr(qr_CAN_PLACE_GANON))
18602
4/4
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 64 times.
✓ Branch 2 taken 64 times.
✓ Branch 3 taken 64 times.
64 || (guysbuf[id].family == eeTRAP && !get_qr(qr_CAN_PLACE_TRAPS))) return false;
18603 [[fallthrough]];
18604 default:
18605
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 81666 times.
81666 if (guysbuf[id].flags&guy_ignoretmpnr) return true;
18606 81666 break;
18607 }
18608
18609
2/2
✓ Branch 0 taken 20879 times.
✓ Branch 1 taken 60787 times.
81666 if(!get_qr(qr_NOTMPNORET))
18610 60787 return !getmapflag(mTMPNORET);
18611
18612 20879 return true;
18613 82771 }
18614
18615 1408915 void activate_fireball_statue(int32_t pos)
18616 {
18617
3/4
✓ Branch 0 taken 287785 times.
✓ Branch 1 taken 1121130 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 287785 times.
1408915 if(!(tmpscr->enemyflags&efFIREBALLS) || statueID<0)
18618 {
18619 1121130 return;
18620 }
18621
18622 287785 int32_t cx=-1000, cy=-1000;
18623 287785 int32_t x = (pos&15)<<4;
18624 287785 int32_t y = pos&0xF0;
18625
18626 287785 int32_t ctype = combobuf[MAPCOMBO(x,y)].type;
18627
18628
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 287785 times.
287785 if(!isfixedtogrid(statueID))
18629 {
18630
2/2
✓ Branch 0 taken 1508 times.
✓ Branch 1 taken 286277 times.
287785 if(ctype==cL_STATUE)
18631 {
18632 1508 cx=x+4;
18633 1508 cy=y+7;
18634 1508 }
18635
2/2
✓ Branch 0 taken 1315 times.
✓ Branch 1 taken 284962 times.
286277 else if(ctype==cR_STATUE)
18636 {
18637 1315 cx=x-8;
18638 1315 cy=y-1;
18639 1315 }
18640
2/2
✓ Branch 0 taken 283749 times.
✓ Branch 1 taken 1213 times.
284962 else if(ctype==cC_STATUE)
18641 {
18642 1213 cx=x;
18643 1213 cy=y;
18644 1213 }
18645 287785 }
18646 else if(ctype==cL_STATUE || ctype==cR_STATUE || ctype==cC_STATUE)
18647 {
18648 cx=x;
18649 cy=y;
18650 }
18651
18652
2/2
✓ Branch 0 taken 283749 times.
✓ Branch 1 taken 4036 times.
287785 if(cx!=-1000) // No point creating it if this is false
18653 {
18654
2/2
✓ Branch 0 taken 9754 times.
✓ Branch 1 taken 4032 times.
13786 for(int32_t j=0; j<guys.Count(); j++)
18655 {
18656
4/4
✓ Branch 0 taken 1698 times.
✓ Branch 1 taken 8056 times.
✓ Branch 2 taken 1694 times.
✓ Branch 3 taken 4 times.
9754 if((int32_t(guys.spr(j)->x)==cx)&&(int32_t(guys.spr(j)->y)==cy))
18657 {
18658
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if((guys.spr(j)->id&0xFFF) == statueID) // There's already a matching enemy here!
18659 4 return; // No point deleting it. A script might be toying with it in some way.
18660 else
18661 guys.del(j);
18662 }
18663 9750 }
18664
18665 4032 addenemy(cx, cy, statueID, !isfixedtogrid(statueID) ? 24 : 0);
18666 4032 }
18667 1408915 }
18668
18669 34907 void activate_fireball_statues()
18670 {
18671
2/2
✓ Branch 0 taken 1413 times.
✓ Branch 1 taken 33494 times.
34907 if(!(tmpscr->enemyflags&efFIREBALLS))
18672 {
18673 33494 return;
18674 }
18675
18676
2/2
✓ Branch 0 taken 1413 times.
✓ Branch 1 taken 248688 times.
250101 for(int32_t i=0; i<176; i++)
18677 {
18678 248688 activate_fireball_statue(i);
18679 248688 }
18680 34907 }
18681
18682 34907 void load_default_enemies()
18683 {
18684 34907 wallm_load_clk=frame-80;
18685
18686
2/2
✓ Branch 0 taken 33027 times.
✓ Branch 1 taken 1880 times.
34907 if(tmpscr->enemyflags&efZORA)
18687 {
18688
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1880 times.
1880 if(zoraID>=0)
18689 1880 addenemy(-16, -16, zoraID, 0);
18690 1880 }
18691
18692
2/2
✓ Branch 0 taken 34729 times.
✓ Branch 1 taken 178 times.
34907 if(tmpscr->enemyflags&efTRAP4)
18693 {
18694
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 178 times.
178 if(cornerTrapID>=0)
18695 {
18696 178 addenemy(32, 32, cornerTrapID, -14);
18697 178 addenemy(208, 32, cornerTrapID, -14);
18698 178 addenemy(32, 128, cornerTrapID, -14);
18699 178 addenemy(208, 128, cornerTrapID, -14);
18700 178 }
18701 178 }
18702
18703
2/2
✓ Branch 0 taken 383977 times.
✓ Branch 1 taken 34907 times.
418884 for(int32_t y=0; y<176; y+=16)
18704 {
18705
2/2
✓ Branch 0 taken 6143632 times.
✓ Branch 1 taken 383977 times.
6527609 for(int32_t x=0; x<256; x+=16)
18706 {
18707 6143632 int32_t ctype = combobuf[MAPCOMBO(x,y)].type;
18708 6143632 int32_t cflag = MAPFLAG(x, y);
18709 6143632 int32_t cflag_i = MAPCOMBOFLAG(x, y);
18710
18711
4/6
✓ Branch 0 taken 6143632 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6143326 times.
✓ Branch 3 taken 306 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 6143326 times.
6143632 if(ctype==cTRAP_H || cflag==mfTRAP_H || cflag_i==mfTRAP_H)
18712 {
18713
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 296 times.
306 if(trapLOSHorizontalID>=0)
18714 296 addenemy(x, y, trapLOSHorizontalID, -14);
18715 306 }
18716
4/6
✓ Branch 0 taken 6143326 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6143120 times.
✓ Branch 3 taken 206 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 6143120 times.
6143326 else if(ctype==cTRAP_V || cflag==mfTRAP_V || cflag_i==mfTRAP_V)
18717 {
18718
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 206 times.
206 if(trapLOSVerticalID>=0)
18719 206 addenemy(x, y, trapLOSVerticalID, -14);
18720 206 }
18721
4/6
✓ Branch 0 taken 6143120 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6142842 times.
✓ Branch 3 taken 278 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 6142842 times.
6143120 else if(ctype==cTRAP_4 || cflag==mfTRAP_4 || cflag_i==mfTRAP_4)
18722 {
18723
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 278 times.
278 if(trapLOS4WayID>=0)
18724 {
18725
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 278 times.
278 if(addenemy(x, y, trapLOS4WayID, -14))
18726 278 guys.spr(guys.Count()-1)->dummy_int[1]=2;
18727 278 }
18728 278 }
18729
18730
4/6
✓ Branch 0 taken 6142842 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6142443 times.
✓ Branch 3 taken 399 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 6142443 times.
6142842 else if(ctype==cTRAP_LR || cflag==mfTRAP_LR || cflag_i==mfTRAP_LR)
18731 {
18732
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 399 times.
399 if(trapConstantHorizontalID>=0)
18733 399 addenemy(x, y, trapConstantHorizontalID, -14);
18734 399 }
18735
4/6
✓ Branch 0 taken 6142443 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6142010 times.
✓ Branch 3 taken 433 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 6142010 times.
6142443 else if(ctype==cTRAP_UD || cflag==mfTRAP_UD || cflag_i==mfTRAP_UD)
18736 {
18737
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 433 times.
433 if(trapConstantVerticalID>=0)
18738 433 addenemy(x, y, trapConstantVerticalID, -14);
18739 433 }
18740
18741
1/2
✓ Branch 0 taken 6143632 times.
✗ Branch 1 not taken.
6143632 if(ctype==cSPINTILE1)
18742 {
18743 // Awaken spinning tile
18744 awaken_spinning_tile(tmpscr,COMBOPOS(x,y));
18745 }
18746 6143632 }
18747 383977 }
18748
18749
2/2
✓ Branch 0 taken 34851 times.
✓ Branch 1 taken 56 times.
34907 if(tmpscr->enemyflags&efTRAP2)
18750 {
18751
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 56 times.
56 if(centerTrapID>=-1)
18752 {
18753
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 56 times.
56 if(addenemy(64, 80, centerTrapID, -14))
18754 56 guys.spr(guys.Count()-1)->dummy_int[1]=1;
18755
18756
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 56 times.
56 if(addenemy(176, 80, centerTrapID, -14))
18757 56 guys.spr(guys.Count()-1)->dummy_int[1]=1;
18758 56 }
18759 56 }
18760
18761
2/2
✓ Branch 0 taken 34824 times.
✓ Branch 1 taken 83 times.
34907 if(tmpscr->enemyflags&efROCKS)
18762 {
18763
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 83 times.
83 if(rockID>=0)
18764 {
18765 83 addenemy(zc_oldrand()&0xF0, 0, rockID, 0);
18766 83 addenemy(zc_oldrand()&0xF0, 0, rockID, 0);
18767 83 addenemy(zc_oldrand()&0xF0, 0, rockID, 0);
18768 83 }
18769 83 }
18770
18771 34907 activate_fireball_statues();
18772 34907 }
18773
18774 44549652 void update_slope_combopos(int32_t lyr, int32_t pos)
18775 {
18776
2/4
✓ Branch 0 taken 44549652 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 44549652 times.
44549652 if(unsigned(lyr) > 6 || unsigned(pos) > 175) return;
18777 44549652 mapscr* s = FFCore.tempScreens[lyr];
18778 44549652 newcombo const& cmb = combobuf[s->data[pos]];
18779
18780 44549652 auto id = (176*lyr)+pos;
18781 44549652 auto it = slopes.find(id);
18782
18783 44549652 bool wasSlope = it!=slopes.end();
18784 44549652 bool isSlope = cmb.type == cSLOPE;
18785
18786
3/4
✓ Branch 0 taken 136 times.
✓ Branch 1 taken 44549516 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 136 times.
44549652 if(isSlope && !wasSlope)
18787 {
18788 136 slopes.try_emplace(id, &(s->data[pos]), nullptr, id, pos);
18789 136 }
18790
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 44549516 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
44549516 else if(wasSlope && !isSlope)
18791 {
18792 slopes.erase(it);
18793 }
18794 44549652 }
18795 35278 void update_slope_comboposes()
18796 {
18797
2/2
✓ Branch 0 taken 246946 times.
✓ Branch 1 taken 35278 times.
282224 for(auto lyr = 0; lyr < 7; ++lyr)
18798 {
18799
2/2
✓ Branch 0 taken 43462496 times.
✓ Branch 1 taken 246946 times.
43709442 for(auto pos = 0; pos < 176; ++pos)
18800 43462496 update_slope_combopos(lyr,pos);
18801 246946 }
18802 35278 }
18803
18804 // Everything that must be done before we change a screen's combo to another combo, or a combo's type to another type.
18805 // There's 2 routines because it's unclear if combobuf or tmpscr->data gets modified. -L
18806 1160227 void screen_combo_modify_preroutine(mapscr *s, int32_t pos)
18807 {
18808 1160227 delete_fireball_shooter(s, pos);
18809 1160227 }
18810
18811 //Placeholder in case we need it.
18812 void screen_ffc_modify_preroutine(word index)
18813 {
18814 return;
18815 }
18816
18817 // Everything that must be done after we change a screen's combo to another combo. -L
18818 1160227 void screen_combo_modify_postroutine(mapscr *s, int32_t pos)
18819 {
18820 1160227 s->valid |= mVALID;
18821 1160227 activate_fireball_statue(pos);
18822
18823
2/2
✓ Branch 0 taken 1160133 times.
✓ Branch 1 taken 94 times.
1160227 if(combobuf[s->data[pos]].type==cSPINTILE1)
18824 {
18825 // Awaken spinning tile
18826 94 awaken_spinning_tile(s,pos);
18827 94 }
18828 1160227 int32_t lyr = -1;
18829
2/2
✓ Branch 0 taken 118155 times.
✓ Branch 1 taken 1042072 times.
1160227 if(s == tmpscr) lyr = 0;
18830
2/2
✓ Branch 0 taken 73071 times.
✓ Branch 1 taken 593895 times.
666966 else for(size_t q = 0; q < 6; ++q)
18831 {
18832
2/2
✓ Branch 0 taken 45084 times.
✓ Branch 1 taken 548811 times.
593895 if(s == tmpscr2+q)
18833 {
18834 45084 lyr = q+1;
18835 45084 break;
18836 }
18837 548811 }
18838
2/2
✓ Branch 0 taken 73071 times.
✓ Branch 1 taken 1087156 times.
1160227 if(lyr > -1)
18839 1087156 update_slope_combopos(lyr,pos);
18840 1160227 }
18841
18842 8785377 void screen_ffc_modify_postroutine(word index)
18843 {
18844 8785377 ffcdata& ff = tmpscr->ffcs[index];
18845 8785377 newcombo const& cmb = combobuf[ff.data];
18846
18847 8785377 auto id = (176*7)+int32_t(index);
18848 8785377 auto it = slopes.find(id);
18849
18850 8785377 bool wasSlope = it!=slopes.end();
18851
1/2
✓ Branch 0 taken 8785377 times.
✗ Branch 1 not taken.
8785377 bool isSlope = cmb.type == cSLOPE && !(ff.flags&ffc_changer);
18852
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 8785377 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
8785377 if(isSlope && !wasSlope)
18853 {
18854 slopes.try_emplace(id, nullptr, &ff, id);
18855 }
18856
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 8785377 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
8785377 else if(wasSlope && !isSlope)
18857 {
18858 slopes.erase(it);
18859 }
18860
18861 8785377 tmpscr->ffcCountMarkDirty();
18862 8785377 }
18863
18864 4404 void screen_combo_modify_pre(int32_t cid)
18865 {
18866
2/2
✓ Branch 0 taken 30828 times.
✓ Branch 1 taken 4404 times.
35232 for(auto lyr = 0; lyr < 7; ++lyr)
18867 {
18868 30828 mapscr* t = FFCore.tempScreens[lyr];
18869
2/2
✓ Branch 0 taken 5425728 times.
✓ Branch 1 taken 30828 times.
5456556 for(int32_t i = 0; i < 176; i++)
18870 {
18871
2/2
✓ Branch 0 taken 5419127 times.
✓ Branch 1 taken 6601 times.
5425728 if(t->data[i] == cid)
18872 {
18873 6601 screen_combo_modify_preroutine(t,i);
18874 6601 }
18875 5425728 }
18876 30828 }
18877 4404 }
18878 4404 void screen_combo_modify_post(int32_t cid)
18879 {
18880
2/2
✓ Branch 0 taken 30828 times.
✓ Branch 1 taken 4404 times.
35232 for(auto lyr = 0; lyr < 7; ++lyr)
18881 {
18882 30828 mapscr* t = FFCore.tempScreens[lyr];
18883
2/2
✓ Branch 0 taken 5425728 times.
✓ Branch 1 taken 30828 times.
5456556 for(int32_t i = 0; i < 176; i++)
18884 {
18885
2/2
✓ Branch 0 taken 5419127 times.
✓ Branch 1 taken 6601 times.
5425728 if(t->data[i] == cid)
18886 {
18887 6601 screen_combo_modify_postroutine(t,i);
18888 6601 }
18889 5425728 }
18890 30828 }
18891
2/2
✓ Branch 0 taken 563712 times.
✓ Branch 1 taken 4404 times.
568116 for(word ind = 0; ind < MAXFFCS; ++ind)
18892 {
18893
2/2
✓ Branch 0 taken 563462 times.
✓ Branch 1 taken 250 times.
563712 if(tmpscr->ffcs[ind].data == cid)
18894 250 screen_ffc_modify_postroutine(ind);
18895 563712 }
18896 4404 }
18897
18898 94 void awaken_spinning_tile(mapscr *s, int32_t pos)
18899 {
18900
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 94 times.
94 addenemy((pos&15)<<4,pos&0xF0,(s->cset[pos]<<12)+eSPINTILE1,combobuf[s->data[pos]].o_tile+zc_max(1,combobuf[s->data[pos]].frames));
18901 94 }
18902
18903
18904 // It stands for next_side_pos
18905 11436 void nsp(bool random)
18906 // moves sle_x and sle_y to the next position
18907 {
18908
2/2
✓ Branch 0 taken 3261 times.
✓ Branch 1 taken 8175 times.
11436 if(random)
18909 {
18910
2/2
✓ Branch 0 taken 1634 times.
✓ Branch 1 taken 1627 times.
3261 if(zc_oldrand()%2)
18911 {
18912 1634 sle_x = (zc_oldrand()%2) ? 0 : 240;
18913 1634 sle_y = (zc_oldrand()%10)*16;
18914 1634 }
18915 else
18916 {
18917 1627 sle_y = (zc_oldrand()%2) ? 0 : 160;
18918 1627 sle_x = (zc_oldrand()%15)*16;
18919 }
18920
18921 3261 return;
18922 }
18923
18924
2/2
✓ Branch 0 taken 6151 times.
✓ Branch 1 taken 2024 times.
8175 if(sle_x==0)
18925 {
18926
2/2
✓ Branch 0 taken 1845 times.
✓ Branch 1 taken 179 times.
2024 if(sle_y<160)
18927 1845 sle_y+=16;
18928 else
18929 179 sle_x+=16;
18930 2024 }
18931
2/2
✓ Branch 0 taken 2581 times.
✓ Branch 1 taken 3570 times.
6151 else if(sle_y==160)
18932 {
18933
2/2
✓ Branch 0 taken 2416 times.
✓ Branch 1 taken 165 times.
2581 if(sle_x<240)
18934 2416 sle_x+=16;
18935 else
18936 165 sle_y-=16;
18937 2581 }
18938
2/2
✓ Branch 0 taken 1550 times.
✓ Branch 1 taken 2020 times.
3570 else if(sle_x==240)
18939 {
18940
2/2
✓ Branch 0 taken 1402 times.
✓ Branch 1 taken 148 times.
1550 if(sle_y>0)
18941 1402 sle_y-=16;
18942 else
18943 148 sle_x-=16;
18944 1550 }
18945
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2020 times.
2020 else if(sle_y==0)
18946 {
18947
1/2
✓ Branch 0 taken 2020 times.
✗ Branch 1 not taken.
2020 if(sle_x>0)
18948 2020 sle_x-=16;
18949 else
18950 sle_y+=16;
18951 2020 }
18952 11436 }
18953
18954 2426 int32_t next_side_pos(bool random)
18955 // moves sle_x and sle_y to the next available position
18956 // returns the direction the enemy should face
18957 {
18958 bool blocked;
18959 2426 int32_t c=0;
18960
18961 2426 do
18962 {
18963
2/2
✓ Branch 0 taken 131 times.
✓ Branch 1 taken 11305 times.
11436 nsp(c>35 ? false : random);
18964
4/4
✓ Branch 0 taken 2444 times.
✓ Branch 1 taken 8992 times.
✓ Branch 2 taken 19 times.
✓ Branch 3 taken 2425 times.
13861 blocked = _walkflag(sle_x,sle_y,2) || _walkflag(sle_x,sle_y+8,2) ||
18965
1/2
✓ Branch 0 taken 2425 times.
✗ Branch 1 not taken.
2425 (combo_class_buf[COMBOTYPE(sle_x,sle_y)].block_enemies ||
18966
2/4
✓ Branch 0 taken 2425 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2425 times.
✗ Branch 3 not taken.
2425 MAPFLAG(sle_x,sle_y) == mfNOENEMY || MAPCOMBOFLAG(sle_x,sle_y)==mfNOENEMY ||
18967
2/4
✓ Branch 0 taken 2425 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2425 times.
2425 MAPFLAG(sle_x,sle_y) == mfNOGROUNDENEMY || MAPCOMBOFLAG(sle_x,sle_y)==mfNOGROUNDENEMY ||
18968 2425 iswaterex(MAPCOMBO(sle_x,sle_y), currmap, currscr, -1, sle_x, sle_y, true));
18969
18970
2/2
✓ Branch 0 taken 11435 times.
✓ Branch 1 taken 1 times.
11436 if(++c>50)
18971 1 return -1;
18972
2/2
✓ Branch 0 taken 9010 times.
✓ Branch 1 taken 2425 times.
11435 }
18973 11435 while(blocked);
18974
18975 2425 int32_t dir=0;
18976
18977
2/2
✓ Branch 0 taken 1690 times.
✓ Branch 1 taken 735 times.
2425 if(sle_x==0) dir=right;
18978
18979
2/2
✓ Branch 0 taken 1856 times.
✓ Branch 1 taken 569 times.
2425 if(sle_y==0) dir=down;
18980
18981
2/2
✓ Branch 0 taken 1719 times.
✓ Branch 1 taken 706 times.
2425 if(sle_x==240) dir=left;
18982
18983
1/2
✓ Branch 0 taken 2425 times.
✗ Branch 1 not taken.
2425 if(sle_y==168) dir=up;
18984
18985 2425 return dir;
18986 2426 }
18987
18988 bool can_side_load(int32_t id)
18989 {
18990 if( ((unsigned)(id&0xFFF)) > MAXGUYS )
18991 {
18992 return false;
18993 }
18994 switch(guysbuf[id].family) //id&0x0FFF)
18995 {
18996 //case eTEK1:
18997 //case eTEK2:
18998 //case eTEK3:
18999 //case eLEV1:
19000 //case eLEV2:
19001 //case eLEV3:
19002 //case eRAQUAM:
19003 //case eLAQUAM:
19004 //case eDODONGO:
19005 //case eMANHAN:
19006 //case eGLEEOK1:
19007 //case eGLEEOK2:
19008 //case eGLEEOK3:
19009 //case eGLEEOK4:
19010 //case eDIG1:
19011 //case eDIG3:
19012 //case eGOHMA1:
19013 //case eGOHMA2:
19014 //case eCENT1:
19015 //case eCENT2:
19016 //case ePATRA1:
19017 //case ePATRA2:
19018 //case eGANON:
19019 //case eMANHAN2:
19020 //case eCEILINGM: later
19021 //case eFLOORM: later
19022 //case ePATRABS:
19023 //case ePATRAL2:
19024 //case ePATRAL3:
19025 //case eGLEEOK1F:
19026 //case eGLEEOK2F:
19027 //case eGLEEOK3F:
19028 //case eGLEEOK4F:
19029 //case eDODONGOBS:
19030 //case eDODONGOF:
19031 //case eGOHMA3:
19032 //case eGOHMA4:
19033 //case eSHOOTMAGIC:
19034 //case eSHOOTROCK:
19035 //case eSHOOTSPEAR:
19036 //case eSHOOTSWORD:
19037 //case eSHOOTFLAME:
19038 //case eSHOOTFLAME2:
19039 //case eSHOOTFBALL:
19040 case eeTEK:
19041 case eeLEV:
19042 case eeAQUA:
19043 case eeDONGO:
19044 case eeMANHAN:
19045 case eeGLEEOK:
19046 case eeDIG:
19047 case eeGHOMA:
19048 case eeLANM:
19049 case eePATRA:
19050 case eeGANON:
19051 case eePROJECTILE:
19052 return false;
19053 break;
19054 }
19055
19056 return true;
19057 }
19058
19059 static bool script_sle = false;
19060 static int32_t sle_pattern = 0;
19061 void script_side_load_enemies()
19062 {
19063 if(script_sle || sle_clk) return;
19064 sle_cnt = 0;
19065 while(sle_cnt<10 && tmpscr->enemy[sle_cnt]!=0)
19066 ++sle_cnt;
19067 script_sle = true;
19068 sle_pattern = tmpscr->pattern;
19069 sle_clk = 0;
19070 }
19071
19072 54442 void side_load_enemies()
19073 {
19074
3/4
✓ Branch 0 taken 54442 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 53760 times.
✓ Branch 3 taken 682 times.
54442 if(!script_sle && sle_clk==0)
19075 {
19076 682 sle_pattern = tmpscr->pattern;
19077 682 sle_cnt = 0;
19078 682 int32_t guycnt = 0;
19079 682 int16_t s = (currmap<<7)+currscr;
19080 682 bool beenhere=false;
19081 682 bool reload=true;
19082 682 bool unbeatablereload = true;
19083
19084 682 load_default_enemies();
19085
19086
2/2
✓ Branch 0 taken 4092 times.
✓ Branch 1 taken 682 times.
4774 for(int32_t i=0; i<6; i++)
19087
2/2
✓ Branch 0 taken 3889 times.
✓ Branch 1 taken 203 times.
4295 if(visited[i]==s)
19088 203 beenhere=true;
19089
19090
2/2
✓ Branch 0 taken 203 times.
✓ Branch 1 taken 479 times.
682 if(!beenhere)
19091 {
19092 479 visited[vhead]=s;
19093 479 vhead = (vhead+1)%6;
19094 479 }
19095
2/2
✓ Branch 0 taken 161 times.
✓ Branch 1 taken 42 times.
203 else if(game->guys[s]==0)
19096 {
19097 42 sle_cnt=0;
19098 42 reload=false;
19099 42 }
19100
19101
2/2
✓ Branch 0 taken 42 times.
✓ Branch 1 taken 640 times.
682 if(reload)
19102 {
19103 640 sle_cnt = game->guys[s];
19104
19105
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 640 times.
✓ Branch 2 taken 420 times.
✓ Branch 3 taken 220 times.
640 if((get_qr(qr_NO_LEAVE_ONE_ENEMY_ALIVE_TRICK) && !beenhere)
19106 640 || sle_cnt==0)
19107 {
19108
4/4
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 1267 times.
✓ Branch 2 taken 1050 times.
✓ Branch 3 taken 220 times.
1270 while(sle_cnt<10 && tmpscr->enemy[sle_cnt]!=0)
19109 1050 ++sle_cnt;
19110 220 }
19111
3/4
✓ Branch 0 taken 479 times.
✓ Branch 1 taken 161 times.
✓ Branch 2 taken 479 times.
✗ Branch 3 not taken.
640 if (!beenhere && get_qr(qr_UNBEATABLES_DONT_KEEP_DEAD))
19112 {
19113 for(int32_t i = 0; i<sle_cnt && tmpscr->enemy[i]>0; i++)
19114 {
19115 if (!(guysbuf[tmpscr->enemy[i]].flags & guy_doesnt_count))
19116 {
19117 unbeatablereload = false;
19118 }
19119 }
19120 if (unbeatablereload)
19121 {
19122 while(sle_cnt<10 && tmpscr->enemy[sle_cnt]!=0)
19123 {
19124 ++sle_cnt;
19125 }
19126 }
19127 }
19128 640 }
19129
19130
3/4
✓ Branch 0 taken 651 times.
✓ Branch 1 taken 31 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 651 times.
682 if((get_qr(qr_ALWAYSRET)) || (tmpscr->flags3&fENEMIESRETURN))
19131 {
19132 31 sle_cnt = 0;
19133
19134
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 139 times.
✓ Branch 2 taken 108 times.
✓ Branch 3 taken 31 times.
139 while(sle_cnt<10 && tmpscr->enemy[sle_cnt]!=0)
19135 108 ++sle_cnt;
19136 31 }
19137
19138
2/2
✓ Branch 0 taken 2442 times.
✓ Branch 1 taken 682 times.
3124 for(int32_t i=0; i<sle_cnt; i++)
19139 2442 ++guycnt;
19140
19141 682 game->guys[s] = guycnt;
19142 682 }
19143
19144
2/2
✓ Branch 0 taken 52016 times.
✓ Branch 1 taken 2426 times.
54442 if((++sle_clk+8)%24 == 0)
19145 {
19146 2426 int32_t dir = next_side_pos(sle_pattern==pSIDESR);
19147
19148
4/4
✓ Branch 0 taken 2425 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 232 times.
✓ Branch 3 taken 2193 times.
2426 if(dir==-1 || tooclose(sle_x,sle_y,32))
19149 {
19150 233 return;
19151 }
19152
19153 2193 int32_t enemy_slot=guys.Count();
19154
19155
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2193 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2193 times.
2193 while(sle_cnt > 0 && !ok2add(tmpscr->enemy[sle_cnt-1]))
19156 sle_cnt--;
19157
19158
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2193 times.
2193 if(sle_cnt > 0)
19159 {
19160
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2193 times.
2193 if(addenemy(sle_x,sle_y,tmpscr->enemy[--sle_cnt],0))
19161 {
19162
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2193 times.
2193 if (((enemy*)guys.spr(enemy_slot))->family != eeTEK)
19163 {
19164 2193 guys.spr(enemy_slot)->dir = dir;
19165 2193 }
19166
1/2
✓ Branch 0 taken 2193 times.
✗ Branch 1 not taken.
2193 if (!get_qr(qr_ENEMIES_DONT_SCRIPT_FIRST_FRAME))
19167 {
19168 if (!FFCore.system_suspend[susptNPCSCRIPTS])
19169 {
19170 guys.spr(enemy_slot)->run_script(MODE_NORMAL);
19171 ((enemy*)guys.spr(enemy_slot))->didScriptThisFrame = true;
19172 }
19173 }
19174 2193 }
19175 2193 }
19176 2193 }
19177
19178
2/2
✓ Branch 0 taken 53631 times.
✓ Branch 1 taken 578 times.
54209 if(sle_cnt<=0)
19179 {
19180
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 578 times.
578 if(script_sle)
19181 script_sle = false;
19182 578 else loaded_enemies=true;
19183 578 sle_clk = 0;
19184 578 }
19185 54442 }
19186
19187 1208109 bool is_starting_pos(int32_t i, int32_t x, int32_t y, int32_t t)
19188 {
19189
19190
4/4
✓ Branch 0 taken 1105225 times.
✓ Branch 1 taken 102884 times.
✓ Branch 2 taken 102884 times.
✓ Branch 3 taken 1208109 times.
1208109 if(tmpscr->enemy[i]<1||tmpscr->enemy[i]>=MAXGUYS) //Hackish fix for crash in Waterford.st on screen 0x65 of dmap 0 (map 1).
19191 {
19192 205768 return false; //never 0, never OoB.
19193 }
19194 // No corner enemies
19195
6/6
✓ Branch 0 taken 1042349 times.
✓ Branch 1 taken 165760 times.
✓ Branch 2 taken 40016 times.
✓ Branch 3 taken 1082365 times.
✓ Branch 4 taken 114320 times.
✓ Branch 5 taken 91456 times.
1208109 if((x==0 || x==240) && (y==0 || y==160))
19196
19197 205776 return false;
19198
19199 //Is a no spawn combo...
19200
4/4
✓ Branch 0 taken 1082353 times.
✓ Branch 1 taken 12 times.
✓ Branch 2 taken 4 times.
✓ Branch 3 taken 1082357 times.
1082365 if(MAPFLAG(x+8,y+8)==mfNOENEMYSPAWN || MAPCOMBOFLAG(x+8,y+8)==mfNOENEMYSPAWN)
19201 16 return false;
19202
19203 // No enemies in dungeon walls
19204
10/10
✓ Branch 0 taken 655073 times.
✓ Branch 1 taken 427284 times.
✓ Branch 2 taken 582513 times.
✓ Branch 3 taken 72560 times.
✓ Branch 4 taken 509953 times.
✓ Branch 5 taken 72560 times.
✓ Branch 6 taken 422881 times.
✓ Branch 7 taken 87072 times.
✓ Branch 8 taken 87072 times.
✓ Branch 9 taken 335809 times.
1082357 if(isdungeon() && (x<32 || x>=224 || y<32 || y>=144))
19205 319264 return false;
19206
19207 // Too close
19208
4/4
✓ Branch 0 taken 74233 times.
✓ Branch 1 taken 688860 times.
✓ Branch 2 taken 101 times.
✓ Branch 3 taken 74132 times.
763093 if(tooclose(x,y,40) && t<11)
19209 74132 return false;
19210
19211 // Can't fly onto it?
19212
4/4
✓ Branch 0 taken 122271 times.
✓ Branch 1 taken 566690 times.
✓ Branch 2 taken 35960 times.
✓ Branch 3 taken 17932 times.
742853 if(isflier(tmpscr->enemy[i])&&
19213
2/2
✓ Branch 0 taken 121881 times.
✓ Branch 1 taken 390 times.
122271 (flyerblocked(x+8,y+8,spw_floater,guysbuf[tmpscr->enemy[i]])||
19214
2/2
✓ Branch 0 taken 53892 times.
✓ Branch 1 taken 67989 times.
121881 (_walkflag(x,y+8,2)&&!get_qr(qr_WALLFLIERS))))
19215 18322 return false;
19216
19217 // Can't jump onto it?
19218 if
19219 (
19220
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 86588 times.
757231 guysbuf[tmpscr->enemy[i]].family==eeTEK
19221
19222
2/2
✓ Branch 0 taken 86606 times.
✓ Branch 1 taken 584033 times.
670639 &&
19223 (
19224
2/2
✓ Branch 0 taken 86599 times.
✓ Branch 1 taken 7 times.
86606 COMBOTYPE(x+8,y+8)==cNOJUMPZONE||
19225
2/2
✓ Branch 0 taken 86598 times.
✓ Branch 1 taken 1 times.
86599 COMBOTYPE(x+8,y+8)==cNOENEMY||
19226
1/2
✓ Branch 0 taken 86598 times.
✗ Branch 1 not taken.
86598 ispitfall(x+8,y+8)||
19227
2/2
✓ Branch 0 taken 86592 times.
✓ Branch 1 taken 6 times.
86598 MAPFLAG(x+8,y+8)==mfNOENEMY||
19228 86592 MAPCOMBOFLAG(x+8,y+8)==mfNOENEMY
19229 )
19230 )
19231 {
19232 18 return false;
19233 }
19234
19235 // Other off-limit combos
19236
6/6
✓ Branch 0 taken 566668 times.
✓ Branch 1 taken 103953 times.
✓ Branch 2 taken 480080 times.
✓ Branch 3 taken 86588 times.
✓ Branch 4 taken 263614 times.
✓ Branch 5 taken 216466 times.
1150701 if((!isflier(tmpscr->enemy[i])&& guysbuf[tmpscr->enemy[i]].family!=eeTEK &&
19237
2/2
✓ Branch 0 taken 268956 times.
✓ Branch 1 taken 211124 times.
480080 (_walkflag(x,y+8,2) || groundblocked(x+8,y+8,guysbuf[tmpscr->enemy[i]]))) &&
19238 480080 guysbuf[tmpscr->enemy[i]].family!=eeZORA)
19239 216466 return false;
19240
19241 // Don't ever generate enemies on these combos!
19242
4/4
✓ Branch 0 taken 453851 times.
✓ Branch 1 taken 304 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 453857 times.
454155 if(COMBOTYPE(x+8,y+8)==cARMOS||COMBOTYPE(x+8,y+8)==cBSGRAVE)
19243 310 return false;
19244
19245 //BS Dodongos need at least 2 spaces.
19246
4/4
✓ Branch 0 taken 1039 times.
✓ Branch 1 taken 452818 times.
✓ Branch 2 taken 1014 times.
✓ Branch 3 taken 25 times.
453857 if((guysbuf[tmpscr->enemy[i]].family==eeDONGO)&&(guysbuf[tmpscr->enemy[i]].attributes[9] ==1))
19247 {
19248
3/4
✓ Branch 0 taken 19 times.
✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 19 times.
25 if(((x<16) ||_walkflag(x-16,y+8, 2))&&
19249
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 3 times.
6 ((x>224)||_walkflag(x+16,y+8, 2))&&
19250
0/2
✗ Branch 0 not taken.
✗ Branch 1 not taken.
6 ((y<16) ||_walkflag(x, y-8, 2))&&
19251 ((y>144)||_walkflag(x, y+24,2)))
19252 {
19253 return false;
19254 }
19255 19 }
19256
19257 453851 return true;
19258 1105225 }
19259
19260 159458 bool is_ceiling_pattern(int32_t i)
19261 {
19262
2/2
✓ Branch 0 taken 20 times.
✓ Branch 1 taken 159438 times.
159458 return (i==pCEILING || i==pCEILINGR);
19263 }
19264
19265 5716 int32_t placeenemy(int32_t i)
19266 {
19267 5716 std::map<int32_t, int32_t> freeposcache;
19268 5716 int32_t frees = 0;
19269
19270
2/2
✓ Branch 0 taken 62876 times.
✓ Branch 1 taken 5716 times.
68592 for(int32_t y=0; y<176; y+=16)
19271 {
19272
2/2
✓ Branch 0 taken 1006016 times.
✓ Branch 1 taken 62876 times.
1068892 for(int32_t x=0; x<256; x+=16)
19273 {
19274
3/4
✓ Branch 0 taken 1006016 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 396120 times.
✓ Branch 3 taken 609896 times.
1006016 if(is_starting_pos(i,x,y,0))
19275 {
19276
1/2
✓ Branch 0 taken 396120 times.
✗ Branch 1 not taken.
396120 freeposcache[frees++] = (y&0xF0)+(x>>4);
19277 396120 }
19278 1006016 }
19279 62876 }
19280
19281
2/2
✓ Branch 0 taken 5705 times.
✓ Branch 1 taken 11 times.
5716 if(frees > 0)
19282
2/4
✓ Branch 0 taken 5705 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5705 times.
✗ Branch 3 not taken.
5705 return freeposcache[zc_oldrand()%frees];
19283
19284 11 return -1;
19285 5716 }
19286
19287 80540 void spawnEnemy(int& pos, int& clk, int& x, int& y, int& fastguys, int& i, int& guycnt, int& loadcnt)
19288 {
19289 80540 bool placed=false;
19290 80540 int32_t t=-1;
19291
19292 // First: enemy combo flags
19293
2/2
✓ Branch 0 taken 800180 times.
✓ Branch 1 taken 63447 times.
863627 for(int32_t sy=0; sy<176; sy+=16)
19294 {
19295
2/2
✓ Branch 0 taken 12675627 times.
✓ Branch 1 taken 783087 times.
13458714 for(int32_t sx=0; sx<256; sx+=16)
19296 {
19297 12675627 int32_t cflag = MAPFLAG(sx, sy);
19298 12675627 int32_t cflag_i = MAPCOMBOFLAG(sx, sy);
19299
19300
2/4
✓ Branch 0 taken 12675627 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12675627 times.
✗ Branch 3 not taken.
12675627 if(((cflag==mfENEMYALL)||(cflag_i==mfENEMYALL)) && (!placed))
19301 {
19302 if(!ok2add(tmpscr->enemy[i]))
19303 {
19304 if (loadcnt < 10 && tmpscr->enemy[i] > 0 && tmpscr->enemy[i] < MAXGUYS) ++loadcnt;
19305 }
19306 else
19307 {
19308 addenemy(sx,
19309 (is_ceiling_pattern(tmpscr->pattern) && isSideViewGravity()) ? -(150+50*guycnt) : sy,
19310 (is_ceiling_pattern(tmpscr->pattern) && !(isSideViewGravity())) ? 150+50*guycnt : 0,tmpscr->enemy[i],-15);
19311
19312 ++guycnt;
19313
19314 placed=true;
19315 goto placed_enemy;
19316 }
19317 }
19318
19319
4/4
✓ Branch 0 taken 12658485 times.
✓ Branch 1 taken 17142 times.
✓ Branch 2 taken 12658485 times.
✓ Branch 3 taken 17142 times.
12675627 else if(((cflag==mfENEMY0+i)||(cflag_i==mfENEMY0+i)) && (!placed))
19320 {
19321
2/2
✓ Branch 0 taken 49 times.
✓ Branch 1 taken 17093 times.
17142 if(!ok2add(tmpscr->enemy[i]))
19322 {
19323
4/6
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 37 times.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 12 times.
49 if (loadcnt < 10 && tmpscr->enemy[i] > 0 && tmpscr->enemy[i] < MAXGUYS) ++loadcnt;
19324 49 }
19325 else
19326 {
19327 34186 addenemy(sx,
19328
3/4
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 17092 times.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
17093 (is_ceiling_pattern(tmpscr->pattern) && isSideViewGravity()) ? -(150+50*guycnt) : sy,
19329
3/4
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 17092 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
17093 (is_ceiling_pattern(tmpscr->pattern) && !(isSideViewGravity())) ? 150+50*guycnt : 0,tmpscr->enemy[i],-15);
19330
19331 17093 ++guycnt;
19332
19333 17093 placed=true;
19334 17093 goto placed_enemy;
19335 }
19336 49 }
19337 12658534 }
19338 783087 }
19339
19340 // Next: enemy pattern
19341
6/8
✓ Branch 0 taken 4939 times.
✓ Branch 1 taken 58508 times.
✓ Branch 2 taken 57952 times.
✓ Branch 3 taken 5495 times.
✓ Branch 4 taken 57952 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 57952 times.
63447 if((tmpscr->pattern==pRANDOM || tmpscr->pattern==pCEILING) && !(isSideViewGravity()) && ((tmpscr->enemy[i]>0&&tmpscr->enemy[i]<MAXGUYS)))
19342 {
19343 57952 do
19344 {
19345
19346 // NES positions
19347 99430 pos%=9;
19348 99430 x=stx[loadside][pos];
19349 99430 y=sty[loadside][pos];
19350 99430 ++pos;
19351 99430 ++t;
19352
2/2
✓ Branch 0 taken 41478 times.
✓ Branch 1 taken 57952 times.
157382 }
19353
2/2
✓ Branch 0 taken 221 times.
✓ Branch 1 taken 99209 times.
99430 while((t< 20) && !is_starting_pos(i,x,y,t));
19354 57952 }
19355
19356
4/4
✓ Branch 0 taken 57952 times.
✓ Branch 1 taken 5495 times.
✓ Branch 2 taken 221 times.
✓ Branch 3 taken 57731 times.
63447 if(t<0 || t >= 20) // above enemy pattern failed
19357 {
19358 // Final chance: find a random position anywhere onscreen
19359 5716 int32_t randpos = placeenemy(i);
19360
19361
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 5705 times.
5716 if(randpos>-1)
19362 {
19363 5705 x=(randpos&15)<<4;
19364 5705 y= randpos&0xF0;
19365 5705 }
19366 else // All opportunities failed - abort
19367 {
19368 11 return;
19369 }
19370 5705 }
19371
19372 {
19373 63436 int32_t c=0;
19374 63436 c=clk;
19375
19376
2/2
✓ Branch 0 taken 9584 times.
✓ Branch 1 taken 53852 times.
63436 if(!slowguy(tmpscr->enemy[i]))
19377 53852 ++fastguys;
19378
2/2
✓ Branch 0 taken 1586 times.
✓ Branch 1 taken 7998 times.
9584 else if(fastguys>0)
19379 1586 c=-15*(i-fastguys+2);
19380 else
19381 7998 c=-15*(i+1);
19382
19383
4/6
✓ Branch 0 taken 28859 times.
✓ Branch 1 taken 34577 times.
✓ Branch 2 taken 28859 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 28859 times.
63436 if(BSZ&&((tmpscr->enemy[i]>0&&tmpscr->enemy[i]<MAXGUYS))) // Hackish fix for crash in Waterford.qst on screen 0x65 of dmap 0 (map 1).
19384 {
19385 // Special case for blue leevers
19386
4/4
✓ Branch 0 taken 1894 times.
✓ Branch 1 taken 26965 times.
✓ Branch 2 taken 761 times.
✓ Branch 3 taken 1133 times.
28859 if(guysbuf[tmpscr->enemy[i]].family==eeLEV && guysbuf[tmpscr->enemy[i]].attributes[0]==1)
19387 761 c=-15*(i+1);
19388 else
19389 28098 c=-15;
19390 28859 }
19391
19392
2/2
✓ Branch 0 taken 62636 times.
✓ Branch 1 taken 800 times.
63436 if(!ok2add(tmpscr->enemy[i]))
19393 {
19394
4/6
✓ Branch 0 taken 130 times.
✓ Branch 1 taken 670 times.
✓ Branch 2 taken 130 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 130 times.
800 if (loadcnt < 10 && tmpscr->enemy[i] > 0 && tmpscr->enemy[i] < MAXGUYS) ++loadcnt;
19395 800 }
19396 else
19397 {
19398
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 62636 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
62636 if(((tmpscr->enemy[i]>0||tmpscr->enemy[i]<MAXGUYS))) // Hackish fix for crash in Waterford.qst on screen 0x65 of dmap 0 (map 1).
19399 {
19400
3/4
✓ Branch 0 taken 130 times.
✓ Branch 1 taken 62506 times.
✓ Branch 2 taken 130 times.
✗ Branch 3 not taken.
125272 addenemy(x,(is_ceiling_pattern(tmpscr->pattern) && isSideViewGravity()) ? -(150+50*guycnt) : y,
19401
3/4
✓ Branch 0 taken 130 times.
✓ Branch 1 taken 62506 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 130 times.
62636 (is_ceiling_pattern(tmpscr->pattern) && !(isSideViewGravity())) ? 150+50*guycnt : 0,tmpscr->enemy[i],c);
19402
19403 62636 ++guycnt;
19404 62636 }
19405 }
19406
19407 63436 placed=true;
19408 63436 } // if(t < 20)
19409
19410 placed_enemy:
19411
19412 // I don't like this, but it seems to work...
19413 static bool foundCarrier;
19414
19415
2/2
✓ Branch 0 taken 59157 times.
✓ Branch 1 taken 21372 times.
80529 if(i==0)
19416 21372 foundCarrier=false;
19417
19418
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 80529 times.
80529 if(placed)
19419 {
19420
4/4
✓ Branch 0 taken 21372 times.
✓ Branch 1 taken 59157 times.
✓ Branch 2 taken 21203 times.
✓ Branch 3 taken 169 times.
80529 if(i==0 && tmpscr->enemyflags&efLEADER)
19421 {
19422 169 int32_t index = guys.idFirst(tmpscr->enemy[i],0xFFF);
19423
19424
2/2
✓ Branch 0 taken 162 times.
✓ Branch 1 taken 7 times.
169 if(index!=-1)
19425 {
19426 //grab the first segment. Not accurate to how older versions did it, but the way they did it might be incompatible with enemy editor.
19427
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 162 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
162 if ((((enemy*)guys.spr(index))->family == eeLANM) && !get_qr(qr_NO_LANMOLA_RINGLEADER)) index = guys.idNth(tmpscr->enemy[i], 2, 0xFFF);
19428
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 162 times.
162 if(index!=-1)
19429 {
19430 162 ((enemy*)guys.spr(index))->leader = true;
19431 162 }
19432 162 }
19433 169 }
19434
19435
4/4
✓ Branch 0 taken 80306 times.
✓ Branch 1 taken 223 times.
✓ Branch 2 taken 80242 times.
✓ Branch 3 taken 64 times.
80529 if(!foundCarrier && hasitem&(4|2))
19436 {
19437 64 int32_t index = guys.idFirst(tmpscr->enemy[i],0xFFF);
19438
19439
2/4
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 64 times.
64 if(index!=-1 && (((enemy*)guys.spr(index))->flags&guy_doesnt_count)==0)
19440 {
19441 64 ((enemy*)guys.spr(index))->itemguy = true;
19442 64 foundCarrier=true;
19443 64 }
19444 64 }
19445 80529 }
19446 80540 }
19447
19448 bool scriptloadenemies()
19449 {
19450 loaded_enemies = true;
19451 if(script_sle || sle_clk) return false;
19452 if(tmpscr->pattern==pNOSPAWN) return false;
19453
19454 if(tmpscr->pattern==pSIDES || tmpscr->pattern==pSIDESR)
19455 {
19456 script_side_load_enemies();
19457 return true;
19458 }
19459
19460 int32_t pos=zc_oldrand()%9;
19461 int32_t clk=-15,x=0,y=0,fastguys=0;
19462 int32_t i=0,guycnt=0;
19463 int32_t loadcnt = 10;
19464
19465 for(; i<loadcnt && tmpscr->enemy[i]>0; i++)
19466 {
19467 int32_t preguycount = guys.Count(); //I'm not experienced enough to know if this is an awful hack but it feels like one.
19468 spawnEnemy(pos, clk, x, y, fastguys, i, guycnt, loadcnt);
19469 if (guys.Count() > preguycount)
19470 {
19471 if (!get_qr(qr_ENEMIES_DONT_SCRIPT_FIRST_FRAME))
19472 {
19473 if (!FFCore.system_suspend[susptNPCSCRIPTS])
19474 {
19475 guys.spr(guys.Count()-1)->run_script(MODE_NORMAL);
19476 ((enemy*)guys.spr(guys.Count()-1))->didScriptThisFrame = true;
19477 }
19478 }
19479 }
19480 --clk;
19481 }
19482 return true;
19483 }
19484
19485 14113227 void loadenemies()
19486 {
19487
3/4
✓ Branch 0 taken 14113227 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 53760 times.
✓ Branch 3 taken 14059467 times.
14113227 if(script_sle || sle_clk)
19488 {
19489 53760 side_load_enemies();
19490 53760 return;
19491 }
19492
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14059467 times.
14059467 if(tmpscr->pattern==pNOSPAWN) return;
19493
2/2
✓ Branch 0 taken 14024470 times.
✓ Branch 1 taken 34997 times.
14059467 if(loaded_enemies)
19494 14024470 return;
19495
19496 // check if it's the dungeon boss and it has been beaten before
19497
4/4
✓ Branch 0 taken 359 times.
✓ Branch 1 taken 34638 times.
✓ Branch 2 taken 269 times.
✓ Branch 3 taken 90 times.
34997 if(tmpscr->enemyflags&efBOSS && game->lvlitems[dlevel]&liBOSS)
19498 {
19499 90 loaded_enemies = true;
19500 90 return;
19501 }
19502
19503
4/4
✓ Branch 0 taken 34466 times.
✓ Branch 1 taken 441 times.
✓ Branch 2 taken 241 times.
✓ Branch 3 taken 34225 times.
34907 if(tmpscr->pattern==pSIDES || tmpscr->pattern==pSIDESR)
19504 {
19505 682 side_load_enemies();
19506 682 return;
19507 }
19508
19509 34225 loaded_enemies=true;
19510
19511 // do enemies that are always loaded
19512 34225 load_default_enemies();
19513
19514 // dungeon basements
19515
19516 static byte dngn_enemy_x[4] = {32,96,144,208};
19517
19518
2/2
✓ Branch 0 taken 904 times.
✓ Branch 1 taken 33321 times.
34225 if(currscr>=128)
19519 {
19520
2/2
✓ Branch 0 taken 429 times.
✓ Branch 1 taken 475 times.
904 if(DMaps[currdmap].flags&dmfCAVES) return;
19521
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 475 times.
475 if ( DMaps[currdmap].flags&dmfNEWCELLARENEMIES )
19522 {
19523 for(int32_t i=0; i<10; i++)
19524 {
19525 if ( tmpscr->enemy[i] )
19526 {
19527 int32_t preguycount = guys.Count();
19528 addenemy(dngn_enemy_x[i],96,tmpscr->enemy[i],-14-i);
19529 if (guys.Count() > preguycount)
19530 {
19531 if (!get_qr(qr_ENEMIES_DONT_SCRIPT_FIRST_FRAME))
19532 {
19533 if (!FFCore.system_suspend[susptNPCSCRIPTS])
19534 {
19535 guys.spr(guys.Count()-1)->run_script(MODE_NORMAL);
19536 ((enemy*)guys.spr(guys.Count()-1))->didScriptThisFrame = true;
19537 }
19538 }
19539 }
19540 }
19541 }
19542 }
19543 else
19544 {
19545
2/2
✓ Branch 0 taken 1900 times.
✓ Branch 1 taken 475 times.
2375 for(int32_t i=0; i<4; i++)
19546 {
19547 1900 int32_t preguycount = guys.Count();
19548
2/2
✓ Branch 0 taken 1044 times.
✓ Branch 1 taken 856 times.
1900 addenemy(dngn_enemy_x[i],96,tmpscr->enemy[i]?tmpscr->enemy[i]:(int32_t)eKEESE1,-14-i);
19549
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1900 times.
1900 if (guys.Count() > preguycount)
19550 {
19551
2/2
✓ Branch 0 taken 1896 times.
✓ Branch 1 taken 4 times.
1900 if (!get_qr(qr_ENEMIES_DONT_SCRIPT_FIRST_FRAME))
19552 {
19553
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if (!FFCore.system_suspend[susptNPCSCRIPTS])
19554 {
19555 4 guys.spr(guys.Count()-1)->run_script(MODE_NORMAL);
19556 4 ((enemy*)guys.spr(guys.Count()-1))->didScriptThisFrame = true;
19557 4 }
19558 4 }
19559 1900 }
19560 1900 }
19561 }
19562 475 return;
19563 }
19564
19565 // check if it's been long enough to reload all enemies
19566
19567 33321 int32_t loadcnt = 10;
19568 33321 int16_t s = (currmap<<7)+currscr;
19569 33321 bool beenhere = false;
19570 33321 bool reload = true;
19571 33321 bool unbeatablereload = true;
19572
19573
2/2
✓ Branch 0 taken 199926 times.
✓ Branch 1 taken 33321 times.
233247 for(int32_t i=0; i<6; i++)
19574
2/2
✓ Branch 0 taken 190760 times.
✓ Branch 1 taken 9166 times.
209092 if(visited[i]==s)
19575 9166 beenhere = true;
19576
19577
2/2
✓ Branch 0 taken 9166 times.
✓ Branch 1 taken 24155 times.
33321 if(!beenhere) //Okay so this basically checks the last 6 unique screen's you've been in and checks if the current screen is one of them.
19578 {
19579 24155 visited[vhead]=s; //If not, it adds it to the array,
19580 24155 vhead = (vhead+1)%6; //which overrides one of the others, and then moves onto the next.
19581 24155 }
19582
2/2
✓ Branch 0 taken 4611 times.
✓ Branch 1 taken 4555 times.
9166 else if(game->guys[s]==0) //Then, if you have been here, and the number of enemies left on the screen is 0,
19583 {
19584 4555 loadcnt = 0; //It will tell it not to load any enemies,
19585 4555 reload = false; //both by setting loadcnt to 0 and making the reload if statement not run.
19586 4555 }
19587
19588
2/2
✓ Branch 0 taken 4555 times.
✓ Branch 1 taken 28766 times.
33321 if(reload) //This if statement is only false if this screen is one of the last 6 screens you visited and you left 0 enemies alive.
19589 {
19590 28766 loadcnt = game->guys[s]; //Otherwise, if this if statement is true, it will try to load the last amount of enemies you left alive.
19591
19592
2/4
✓ Branch 0 taken 10143 times.
✓ Branch 1 taken 18623 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
28766 if(loadcnt==0 || //Then, if the number of enemies is 0, that means you left 0 enemies alive on a screen but haven't been there in the past 6 screens.
19593
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10143 times.
10143 (get_qr(qr_NO_LEAVE_ONE_ENEMY_ALIVE_TRICK) && !beenhere)) //Alternatively, if you have the quest rule enabled that always respawns all enemies after a period of time, and you haven't been here in 6 screens.
19594 18623 loadcnt = 10; //That means all enemies need to be respawned.
19595
3/4
✓ Branch 0 taken 24155 times.
✓ Branch 1 taken 4611 times.
✓ Branch 2 taken 24155 times.
✗ Branch 3 not taken.
28766 if (!beenhere && get_qr(qr_UNBEATABLES_DONT_KEEP_DEAD))
19596 {
19597 for(int32_t i = 0; i<loadcnt && tmpscr->enemy[i]>0; i++)
19598 {
19599 if (!(guysbuf[tmpscr->enemy[i]].flags & guy_doesnt_count))
19600 {
19601 unbeatablereload = false;
19602 }
19603 }
19604 if (unbeatablereload)
19605 {
19606 loadcnt = 10;
19607 }
19608 }
19609 28766 }
19610
19611
4/4
✓ Branch 0 taken 31862 times.
✓ Branch 1 taken 1459 times.
✓ Branch 2 taken 187 times.
✓ Branch 3 taken 31675 times.
33321 if((get_qr(qr_ALWAYSRET)) || (tmpscr->flags3&fENEMIESRETURN)) //If enemies always return is enabled quest-wide or for this screen,
19612 1646 loadcnt = 10; //All enemies also need to be respawned.
19613
19614 33321 int32_t pos=zc_oldrand()%9; //This sets up a variable for spawnEnemy to edit so as to spawn the enemies pseudo-randomly.
19615 33321 int32_t clk=-15,x=0,y=0,fastguys=0; //clk being negative means the enemy is in its spawn poof.
19616 33321 int32_t i=0,guycnt=0; //Lastly, resets guycnt to 0 so spawnEnemy can increment it manually per-enemy.
19617
19618
4/4
✓ Branch 0 taken 14555 times.
✓ Branch 1 taken 99306 times.
✓ Branch 2 taken 80540 times.
✓ Branch 3 taken 33321 times.
113861 for(; i<loadcnt && tmpscr->enemy[i]>0; i++)
19619 {
19620 80540 int32_t preguycount = guys.Count(); //I'm not experienced enough to know if this is an awful hack but it feels like one.
19621 80540 spawnEnemy(pos, clk, x, y, fastguys, i, guycnt, loadcnt);
19622
2/2
✓ Branch 0 taken 811 times.
✓ Branch 1 taken 79729 times.
80540 if (guys.Count() > preguycount)
19623 {
19624
2/2
✓ Branch 0 taken 77382 times.
✓ Branch 1 taken 2347 times.
79729 if (!get_qr(qr_ENEMIES_DONT_SCRIPT_FIRST_FRAME))
19625 {
19626
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 2343 times.
2347 if (!FFCore.system_suspend[susptNPCSCRIPTS])
19627 {
19628 2343 guys.spr(guys.Count()-1)->run_script(MODE_NORMAL);
19629 2343 ((enemy*)guys.spr(guys.Count()-1))->didScriptThisFrame = true;
19630 2343 }
19631 2347 }
19632 79729 }
19633
19634 80540 --clk; //Each additional enemy spawns with a slightly longer spawn poof than the previous.
19635 80540 }
19636
19637 33321 game->guys[s] = guycnt;
19638 //} //if(true)
19639 14113227 }
19640 233 void moneysign()
19641 {
19642 233 additem(48,108,iRupy,ipDUMMY);
19643 233 set_clip_state(pricesdisplaybuf, 0);
19644 233 textout_ex(pricesdisplaybuf,get_zc_font(font_zfont),"X",64,112,CSET(0)+1,-1);
19645 233 }
19646
19647 3251 void putprices(bool sign)
19648 {
19649
2/2
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 3222 times.
3251 if(fadeclk > 0) return;
19650
19651 3222 rectfill(pricesdisplaybuf, 72, 112, pricesdisplaybuf->w-1, pricesdisplaybuf->h-1, 0);
19652 3222 int32_t step=32;
19653 3222 int32_t x=80;
19654
19655
2/2
✓ Branch 0 taken 281 times.
✓ Branch 1 taken 2941 times.
3222 if(prices[2]==0)
19656 {
19657 2941 step<<=1;
19658
19659
2/2
✓ Branch 0 taken 2909 times.
✓ Branch 1 taken 32 times.
2941 if(prices[1]==0)
19660 {
19661 2909 x=112;
19662 2909 }
19663 2941 }
19664
19665
2/2
✓ Branch 0 taken 3222 times.
✓ Branch 1 taken 9666 times.
12888 for(int32_t i=0; i<3; i++)
19666 {
19667 // Kind of stupid, but it works: 100000 is used to indicate that an item
19668 // has a price of zero rather than there being no item.
19669 // 100000 isn't a valid price, so this doesn't cause problems.
19670
3/4
✓ Branch 0 taken 1039 times.
✓ Branch 1 taken 8627 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1039 times.
9666 if(prices[i]!=0 && prices[i]<100000)
19671 {
19672 char buf[8];
19673 1039 sprintf(buf,sign?"%+3d":"%3d",prices[i]);
19674
19675 1039 int32_t l=(int32_t)strlen(buf);
19676 1039 set_clip_state(pricesdisplaybuf, 0);
19677
2/2
✓ Branch 0 taken 27 times.
✓ Branch 1 taken 1012 times.
1039 textout_ex(pricesdisplaybuf,get_zc_font(font_zfont),buf,x-(l>3?(l-3)<<3:0),112,CSET(0)+1,-1);
19678 1039 }
19679
19680 9666 x+=step;
19681 9666 }
19682 3251 }
19683
19684 // Setting up special rooms
19685 // Also called when the Letter is used successfully.
19686 1201 void setupscreen()
19687 {
19688 1201 boughtsomething=false;
19689 1201 int32_t t=currscr<128?0:1;
19690 1201 word str=tmpscr[t].str;
19691
19692 // Prices are already set to 0 in dowarp()
19693
14/15
✓ Branch 0 taken 174 times.
✓ Branch 1 taken 683 times.
✓ Branch 2 taken 161 times.
✓ Branch 3 taken 28 times.
✓ Branch 4 taken 44 times.
✓ Branch 5 taken 11 times.
✓ Branch 6 taken 13 times.
✓ Branch 7 taken 2 times.
✓ Branch 8 taken 2 times.
✓ Branch 9 taken 17 times.
✓ Branch 10 taken 32 times.
✓ Branch 11 taken 1 times.
✓ Branch 12 taken 19 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 14 times.
1201 switch(tmpscr[t].room)
19694 {
19695 case rSP_ITEM: // special item
19696 161 additem(120,89,tmpscr[t].catchall,ipONETIME2+ipHOLDUP+ipCHECK | ((tmpscr->flags8&fITEMSECRET) ? ipSECRETS : 0));
19697 161 break;
19698
19699 case rINFO: // pay for info
19700 {
19701 28 int32_t count = 0;
19702 28 int32_t base = 88;
19703 28 int32_t step = 5;
19704
19705 28 moneysign();
19706
19707
2/2
✓ Branch 0 taken 28 times.
✓ Branch 1 taken 84 times.
112 for(int32_t i=0; i<3; i++)
19708 {
19709
1/2
✓ Branch 0 taken 84 times.
✗ Branch 1 not taken.
84 if(QMisc.info[tmpscr[t].catchall].str[i])
19710 {
19711 84 ++count;
19712 84 }
19713 else
19714 break;
19715 84 }
19716
19717
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28 times.
28 if(count)
19718 {
19719
1/2
✓ Branch 0 taken 28 times.
✗ Branch 1 not taken.
28 if(count==1)
19720 {
19721 base = 88+32;
19722 }
19723
19724
1/2
✓ Branch 0 taken 28 times.
✗ Branch 1 not taken.
28 if(count==2)
19725 {
19726 step = 6;
19727 }
19728
19729
2/2
✓ Branch 0 taken 84 times.
✓ Branch 1 taken 28 times.
112 for(int32_t i=0; i < count; i++)
19730 {
19731 84 additem((i << step)+base, 89, iRupy, ipMONEY + ipDUMMY);
19732 84 ((item*)items.spr(items.Count()-1))->PriceIndex = i;
19733 84 prices[i] = -(QMisc.info[tmpscr[t].catchall].price[i]);
19734
1/2
✓ Branch 0 taken 84 times.
✗ Branch 1 not taken.
84 if(prices[i]==0)
19735 prices[i]=100000; // So putprices() knows there's an item here and positions the price correctly
19736 84 int32_t itemid = current_item_id(itype_wealthmedal);
19737
19738
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 84 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
84 if(itemid>=0 && prices[i]!=100000)
19739 {
19740 if(itemsbuf[itemid].flags & item_flag1)
19741 prices[i]=((prices[i]*itemsbuf[itemid].misc1)/100);
19742 else
19743 prices[i]-=itemsbuf[itemid].misc1;
19744 prices[i]=vbound(prices[i], -99999, 0);
19745 if(prices[i]==0)
19746 prices[i]=100000;
19747 }
19748
19749
2/6
✓ Branch 0 taken 84 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 84 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
84 if((QMisc.info[tmpscr[t].catchall].price[i])>1 && prices[i]>-1 && prices[i]!=100000)
19750 prices[i]=-1;
19751 84 }
19752 28 }
19753
19754 28 break;
19755 }
19756
19757 case rMONEY: // secret money
19758 44 additem(120,89,iRupy,ipONETIME+ipDUMMY+ipMONEY);
19759 44 ((item*)items.spr(items.Count()-1))->PriceIndex = 0;
19760 44 break;
19761
19762 case rGAMBLE: // gambling
19763 11 prices[0]=prices[1]=prices[2]=-10;
19764 11 moneysign();
19765 11 additem(88,89,iRupy,ipMONEY+ipDUMMY);
19766 11 ((item*)items.spr(items.Count()-1))->PriceIndex = 0;
19767 11 additem(120,89,iRupy,ipMONEY+ipDUMMY);
19768 11 ((item*)items.spr(items.Count()-1))->PriceIndex = 1;
19769 11 additem(152,89,iRupy,ipMONEY+ipDUMMY);
19770 11 ((item*)items.spr(items.Count()-1))->PriceIndex = 2;
19771 11 break;
19772
19773 case rREPAIR: // door repair
19774
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 setmapflag((currscr < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM);
19775 // }
19776 13 repaircharge=tmpscr[t].catchall;
19777 13 break;
19778
19779 case rMUPGRADE: // upgrade magic
19780 2 adjustmagic=true;
19781 2 break;
19782
19783 case rLEARNSLASH: // learn slash attack
19784 2 learnslash=true;
19785 2 break;
19786
19787 case rRP_HC: // heart container or red potion
19788 17 additem(88,89,iRPotion,ipONETIME2+ipHOLDUP+ipFADE);
19789 17 ((item*)items.spr(items.Count()-1))->PriceIndex = 0;
19790 17 additem(152,89,iHeartC,ipONETIME2+ipHOLDUP+ipFADE);
19791 17 ((item*)items.spr(items.Count()-1))->PriceIndex = 1;
19792 17 break;
19793
19794 case rP_SHOP: // potion shop
19795
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 20 times.
32 if(current_item(itype_letter)<i_letter_used)
19796 {
19797 12 str=0;
19798 12 break;
19799 }
19800
19801 [[fallthrough]];
19802 case rTAKEONE: // take one
19803 case rSHOP: // shop
19804 {
19805 194 int32_t count = 0;
19806 194 int32_t base = 88;
19807 194 int32_t step = 5;
19808
19809
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 193 times.
194 if(tmpscr[t].room != rTAKEONE)
19810 193 moneysign();
19811
19812 //count and align the stuff
19813
2/2
✓ Branch 0 taken 157 times.
✓ Branch 1 taken 560 times.
717 for(int32_t i=0; i<3; ++i)
19814 {
19815
2/2
✓ Branch 0 taken 523 times.
✓ Branch 1 taken 37 times.
560 if(QMisc.shop[tmpscr[t].catchall].hasitem[count] != 0)
19816 {
19817 523 ++count;
19818 523 }
19819 else
19820 {
19821 37 break;
19822 }
19823 523 }
19824
19825
2/2
✓ Branch 0 taken 172 times.
✓ Branch 1 taken 22 times.
194 if(count==1)
19826 {
19827 22 base = 88+32;
19828 22 }
19829
19830
2/2
✓ Branch 0 taken 179 times.
✓ Branch 1 taken 15 times.
194 if(count==2)
19831 {
19832 15 step = 6;
19833 15 }
19834
19835
2/2
✓ Branch 0 taken 523 times.
✓ Branch 1 taken 194 times.
717 for(int32_t i=0; i<count; i++)
19836 {
19837 523 additem((i<<step)+base, 89, QMisc.shop[tmpscr[t].catchall].item[i], ipHOLDUP+ipFADE+(tmpscr[t].room == rTAKEONE ? ipONETIME2 : ipCHECK));
19838 523 ((item*)items.spr(items.Count()-1))->PriceIndex = i;
19839
19840
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 521 times.
523 if(tmpscr[t].room != rTAKEONE)
19841 {
19842 521 prices[i] = QMisc.shop[tmpscr[t].catchall].price[i];
19843
1/2
✓ Branch 0 taken 521 times.
✗ Branch 1 not taken.
521 if(prices[i]==0)
19844 prices[i]=100000; // So putprices() knows there's an item here and positions the price correctly
19845 521 int32_t itemid = current_item_id(itype_wealthmedal);
19846
19847
3/4
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 512 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 9 times.
521 if(itemid>=0 && prices[i]!=100000)
19848 {
19849
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(itemsbuf[itemid].flags & item_flag1)
19850 9 prices[i]=((prices[i]*itemsbuf[itemid].misc1) / 100);
19851 else
19852 prices[i]+=itemsbuf[itemid].misc1;
19853 9 prices[i]=vbound(prices[i], 0, 99999);
19854
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(prices[i]==0)
19855 prices[i]=100000;
19856 9 }
19857
19858
2/4
✓ Branch 0 taken 521 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 521 times.
✗ Branch 3 not taken.
521 if((QMisc.shop[tmpscr[t].catchall].price[i])>1 && prices[i]<1)
19859 prices[i]=1;
19860 521 }
19861 523 }
19862
19863 194 break;
19864 }
19865 case rBOTTLESHOP: // bottle shop
19866 {
19867 1 int32_t count = 0;
19868 1 int32_t base = 88;
19869 1 int32_t step = 5;
19870
19871 1 moneysign();
19872 1 bottleshoptype const& bst = QMisc.bottle_shop_types[tmpscr[t].catchall];
19873 //count and align the stuff
19874
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 3 times.
4 for(int32_t i=0; i<3; ++i)
19875 {
19876
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(bst.fill[count] != 0)
19877 {
19878 3 ++count;
19879 3 }
19880 else
19881 {
19882 break;
19883 }
19884 3 }
19885
19886
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(count==1)
19887 {
19888 base = 88+32;
19889 }
19890
19891
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(count==2)
19892 {
19893 step = 6;
19894 }
19895
19896
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 1 times.
4 for(int32_t i=0; i<count; i++)
19897 {
19898 3 adddummyitem((i<<step)+base, 89, /*Use item 0 as a dummy...*/0, ipHOLDUP+ipFADE+ipCHECK);
19899 //{ Setup dummy item
19900 3 item* curItem = ((item*)items.spr(items.Count()-1));
19901 3 curItem->PriceIndex = i;
19902 3 newcombo const& cmb = combobuf[bst.comb[i]];
19903 3 curItem->o_tile = cmb.o_tile;
19904 3 curItem->o_cset = bst.cset[i];
19905 3 curItem->cs = curItem->o_cset;
19906 3 curItem->tile = cmb.o_tile;
19907 3 curItem->o_speed = cmb.speed;
19908 3 curItem->o_delay = 0;
19909 3 curItem->frames = cmb.frames;
19910 3 curItem->flip = cmb.flip;
19911 3 curItem->family = itype_bottlefill; //no pickup w/o empty bottle
19912 3 curItem->pstring = 0;
19913 3 curItem->pickup = ipHOLDUP+ipFADE+ipCHECK;
19914 3 curItem->flash = false;
19915 3 curItem->twohand = false;
19916 3 curItem->anim = true;
19917 3 curItem->hit_width=1;
19918 3 curItem->hyofs=4;
19919 3 curItem->hit_height=12;
19920 3 curItem->script=0;
19921 3 curItem->txsz=1;
19922 3 curItem->tysz=1;
19923 //}
19924
19925 3 prices[i] = bst.price[i];
19926
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(prices[i]==0)
19927 prices[i]=100000; // So putprices() knows there's an item here and positions the price correctly
19928 3 int32_t itemid = current_item_id(itype_wealthmedal);
19929
19930
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3 if(itemid>=0 && prices[i]!=100000)
19931 {
19932 if(itemsbuf[itemid].flags & item_flag1)
19933 prices[i]=((prices[i]*itemsbuf[itemid].misc1)/100);
19934 else
19935 prices[i]+=itemsbuf[itemid].misc1;
19936 prices[i]=vbound(prices[i], 0, 99999);
19937 if(prices[i]==0)
19938 prices[i]=100000;
19939 }
19940
19941
2/4
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
3 if((bst.price[i])>1 && prices[i]<1)
19942 prices[i]=1;
19943 3 }
19944
19945 1 break;
19946 }
19947
19948 case rBOMBS: // more bombs
19949 19 additem(120,89,iRupy,ipDUMMY+ipMONEY);
19950 19 ((item*)items.spr(items.Count()-1))->PriceIndex = 0;
19951 19 prices[0]=-tmpscr[t].catchall;
19952 19 break;
19953
19954 case rARROWS: // more arrows
19955 additem(120,89,iRupy,ipDUMMY+ipMONEY);
19956 ((item*)items.spr(items.Count()-1))->PriceIndex = 0;
19957 prices[0]=-tmpscr[t].catchall;
19958 break;
19959
19960 case rSWINDLE: // leave heart container or money
19961 14 additem(88,89,iHeartC,ipDUMMY+ipMONEY);
19962 14 ((item*)items.spr(items.Count()-1))->PriceIndex = 0;
19963 14 prices[0]=-1;
19964 14 additem(152,89,iRupy,ipDUMMY+ipMONEY);
19965 14 ((item*)items.spr(items.Count()-1))->PriceIndex = 1;
19966 14 prices[1]=-tmpscr[t].catchall;
19967 14 break;
19968
19969 }
19970
19971
3/4
✓ Branch 0 taken 1182 times.
✓ Branch 1 taken 19 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1182 times.
1201 if(tmpscr[t].room == rBOMBS || tmpscr[t].room == rARROWS)
19972 {
19973 19 int32_t i = (tmpscr[t].room == rSWINDLE ? 1 : 0);
19974 19 int32_t itemid = current_item_id(itype_wealthmedal);
19975
19976
1/2
✓ Branch 0 taken 19 times.
✗ Branch 1 not taken.
19 if(itemid >= 0)
19977 {
19978 if(itemsbuf[itemid].flags & item_flag1)
19979 prices[i]*=(itemsbuf[itemid].misc1 /100.0);
19980 else
19981 prices[i]+=itemsbuf[itemid].misc1;
19982 }
19983
19984
2/4
✓ Branch 0 taken 19 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 19 times.
✗ Branch 3 not taken.
19 if(tmpscr[t].catchall>1 && prices[i]>-1)
19985 prices[i]=-1;
19986 19 }
19987
19988 1201 putprices(false);
19989
19990
2/2
✓ Branch 0 taken 1142 times.
✓ Branch 1 taken 59 times.
1201 if(str)
19991 {
19992 1142 donewmsg(str);
19993 1142 }
19994 else
19995 {
19996 59 Hero.unfreeze();
19997 }
19998 1201 }
19999
20000 // Increments msgptr and returns the control code argument pointed at.
20001 3409 word grab_next_argument()
20002 {
20003
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3409 times.
3409 if(unsigned(msgptr+1)>=MsgStrings[msgstr].s.size()) return 0;
20004 3409 byte val=MsgStrings[msgstr].s[++msgptr]-1;
20005 3409 word ret=val;
20006
20007 // If an argument is succeeded by 255, then it's a three-byte argument -
20008 // between 254 and 65535 (or whatever the maximum actually is)
20009
2/2
✓ Branch 0 taken 3285 times.
✓ Branch 1 taken 109 times.
3409 if((unsigned(msgptr+2)<MsgStrings[msgstr].s.size())
20010
2/2
✓ Branch 0 taken 3394 times.
✓ Branch 1 taken 15 times.
3409 && uint8_t(MsgStrings[msgstr].s[msgptr+1]) == 255)
20011 {
20012 109 val=MsgStrings[msgstr].s[msgptr+2];
20013 109 word next=val;
20014 109 ret += 254*next;
20015 109 msgptr+=2;
20016 109 }
20017
20018 3409 return ret;
20019 3409 }
20020
20021 enum
20022 {
20023 MNU_CURSOR_TILE, MNU_CURSOR_CSET,
20024 MNU_CURSOR_WID, MNU_CURSOR_HEI, MNU_CURSOR_FLIP,
20025
20026 MNU_CHOSEN, MNU_TIMER, MNU_CAN_CONFIRM,
20027
20028 MNU_DATA_MAX
20029 };
20030 struct menu_choice
20031 {
20032 int32_t x, y;
20033 int32_t pos;
20034 int32_t upos, dpos, lpos, rpos;
20035 8 menu_choice() : x(0), y(0), pos(0), upos(0), dpos(0), lpos(0), rpos(0)
20036 8 {}
20037 8 menu_choice(int32_t x, int32_t y, int32_t pos, int32_t upos,
20038 int32_t dpos, int32_t lpos, int32_t rpos)
20039 8 : x(x), y(y), pos(pos), upos(upos), dpos(dpos), lpos(lpos), rpos(rpos)
20040 8 {}
20041 };
20042 static int32_t msg_menu_data[MNU_DATA_MAX];
20043 static bool do_run_menu = false;
20044 bool do_end_str = false;
20045 static bool wait_advance = false;
20046 329 static std::map<int32_t, menu_choice> menu_options;
20047 43049 void clr_msg_data()
20048 {
20049 43049 do_end_str = false;
20050 43049 wait_advance = false;
20051 43049 do_run_menu = false;
20052 43049 menu_options.clear();
20053 43049 memset(msg_menu_data, 0, sizeof(msg_menu_data));
20054 43049 }
20055
20056 static bool doing_name_insert = false;
20057 static char namebuf[9] = {0};
20058 static char* nameptr = NULL;
20059 static int32_t ssc_tile_hei = -1, ssc_tile_hei_buf = -1;
20060 965 bool runMenuCursor()
20061 {
20062 965 clear_bitmap(msg_menu_bmp_buf);
20063
1/2
✓ Branch 0 taken 965 times.
✗ Branch 1 not taken.
965 if(!menu_options.size())
20064 {
20065 msg_menu_data[MNU_CHOSEN] = 0;
20066 return true; //end menu
20067 }
20068 965 int32_t pos = msg_menu_data[MNU_CHOSEN];
20069 //If the cursor is at an invalid pos, find the first pos >= 0...
20070
1/2
✓ Branch 0 taken 965 times.
✗ Branch 1 not taken.
965 if(menu_options.find(pos) == menu_options.end())
20071 {
20072 pos = 0;
20073 while(menu_options.find(pos) == menu_options.end())
20074 ++pos;
20075 }
20076 965 menu_choice* ch = &menu_options[pos];
20077
20078 965 bool pressed = true;
20079
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 964 times.
965 if(rUp()) pos = ch->upos;
20080
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 962 times.
964 else if(rDown()) pos = ch->dpos;
20081
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 962 times.
962 else if(rLeft()) pos = ch->lpos;
20082
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 962 times.
962 else if(rRight()) pos = ch->rpos;
20083 962 else pressed = false;
20084
20085
2/2
✓ Branch 0 taken 962 times.
✓ Branch 1 taken 3 times.
965 if(pressed)
20086 3 msg_menu_data[MNU_TIMER] = 1;
20087
20088 965 bool hold_input = !((msg_menu_data[MNU_TIMER]++) % 20);
20089 965 bool held = false;
20090
2/2
✓ Branch 0 taken 917 times.
✓ Branch 1 taken 48 times.
965 if(hold_input)
20091 {
20092 48 held = true;
20093
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 48 times.
48 if(Up()) pos = ch->upos;
20094
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 48 times.
48 else if(Down()) pos = ch->dpos;
20095
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 48 times.
48 else if(Left()) pos = ch->lpos;
20096
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 48 times.
48 else if(Right()) pos = ch->rpos;
20097 48 else held = false;
20098 48 }
20099 //If the cursor is at an invalid pos, find the first pos >= 0...
20100
1/2
✓ Branch 0 taken 965 times.
✗ Branch 1 not taken.
965 if(menu_options.find(pos) == menu_options.end())
20101 {
20102 pos = 0;
20103 while(menu_options.find(pos) == menu_options.end())
20104 ++pos;
20105 }
20106
4/4
✓ Branch 0 taken 962 times.
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 962 times.
✓ Branch 3 taken 3 times.
965 if((pressed || held) && pos != msg_menu_data[MNU_CHOSEN])
20107 3 sfx(MsgStrings[msgstr].sfx);
20108
20109 965 ch = &menu_options[pos];
20110 1930 overtileblock16(msg_menu_bmp_buf, msg_menu_data[MNU_CURSOR_TILE],
20111 965 ch->x, ch->y, (int32_t)ceil(msg_menu_data[MNU_CURSOR_WID]/16.0),
20112 965 (int32_t)ceil(msg_menu_data[MNU_CURSOR_HEI]/16.0),
20113 965 msg_menu_data[MNU_CURSOR_CSET], msg_menu_data[MNU_CURSOR_FLIP]);
20114
20115 965 msg_menu_data[MNU_CHOSEN] = pos;
20116
20117
2/2
✓ Branch 0 taken 941 times.
✓ Branch 1 taken 24 times.
965 if(!msg_menu_data[MNU_CAN_CONFIRM]) //Prevent instantly accepting when holding A
20118 {
20119 24 rAbtn(); //Eat
20120
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 2 times.
24 if(!cAbtn()) msg_menu_data[MNU_CAN_CONFIRM] = 1;
20121 24 }
20122
20123
3/4
✓ Branch 0 taken 962 times.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 962 times.
965 bool ret = (pressed || held) ? false : rAbtn();
20124 //Eat inputs
20125 965 rUp(); rDown(); rLeft(); rRight(); rAbtn();
20126
20127
2/2
✓ Branch 0 taken 963 times.
✓ Branch 1 taken 2 times.
965 if(ret)
20128 2 menu_options.clear();
20129
20130 965 return ret;
20131 //false if pos changed this frame; no confirming while moving the cursor!
20132 965 }
20133
20134 673819 bool bottom_margin_clip()
20135 {
20136 709016 return !get_qr(qr_OLD_STRING_EDITOR_MARGINS)
20137
2/2
✓ Branch 0 taken 638622 times.
✓ Branch 1 taken 35197 times.
673819 && cursor_y >= (msg_h + (get_qr(qr_STRING_FRAME_OLD_WIDTH_HEIGHT)?16:0) - msg_margins[down]);
20138 }
20139
20140 void update_msgstr();
20141 242981 bool parsemsgcode()
20142 {
20143
2/2
✓ Branch 0 taken 2687 times.
✓ Branch 1 taken 240294 times.
242981 if(msgptr>=MsgStrings[msgstr].s.size()) return false;
20144 240294 byte c = byte(MsgStrings[msgstr].s[msgptr]-1);
20145
18/39
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 237259 times.
✓ Branch 2 taken 1276 times.
✓ Branch 3 taken 1463 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 33 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 2 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 68 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✓ Branch 13 taken 9 times.
✓ Branch 14 taken 17 times.
✓ Branch 15 taken 7 times.
✓ Branch 16 taken 6 times.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✓ Branch 24 taken 122 times.
✓ Branch 25 taken 13 times.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
✗ Branch 28 not taken.
✓ Branch 29 taken 2 times.
✓ Branch 30 taken 8 times.
✓ Branch 31 taken 2 times.
✓ Branch 32 taken 4 times.
✓ Branch 33 taken 1 times.
✗ Branch 34 not taken.
✗ Branch 35 not taken.
✗ Branch 36 not taken.
✗ Branch 37 not taken.
✗ Branch 38 not taken.
240294 switch(c)
20146 {
20147 case MSGC_NEWLINE:
20148 {
20149 1276 ssc_tile_hei = ssc_tile_hei_buf;
20150
1/2
✓ Branch 0 taken 1276 times.
✗ Branch 1 not taken.
1276 int32_t thei = zc_max(ssc_tile_hei, text_height(msgfont));
20151 1276 ssc_tile_hei_buf = -1;
20152 1276 cursor_y += thei + MsgStrings[msgstr].vspace;
20153 1276 cursor_x=msg_margins[left];
20154 1276 return true;
20155 }
20156
20157 case MSGC_COLOUR:
20158 {
20159 1463 int32_t cset = (grab_next_argument());
20160 1463 msgcolour = CSET(cset)+(grab_next_argument());
20161 1463 return true;
20162 }
20163
20164 case MSGC_SHDCOLOR:
20165 {
20166 int32_t cset = (grab_next_argument());
20167 msg_shdcol = CSET(cset)+(grab_next_argument());
20168 return true;
20169 }
20170 case MSGC_SHDTYPE:
20171 {
20172 msg_shdtype = grab_next_argument();
20173 return true;
20174 }
20175
20176 case MSGC_SPEED:
20177 {
20178 33 msgspeed=grab_next_argument();
20179 33 return true;
20180 }
20181
20182 case MSGC_CTRUP:
20183 {
20184 int32_t a1 = grab_next_argument();
20185 int32_t a2 = grab_next_argument();
20186 game->change_counter(a2, a1);
20187 return true;
20188 }
20189
20190 case MSGC_CTRDN:
20191 {
20192 2 int32_t a1 = grab_next_argument();
20193 2 int32_t a2 = grab_next_argument();
20194 2 game->change_counter(-a2, a1);
20195 2 return true;
20196 }
20197
20198 case MSGC_CTRSET:
20199 {
20200 int32_t a1 = grab_next_argument();
20201 int32_t a2 = grab_next_argument();
20202 game->set_counter(vbound(a2, 0, game->get_maxcounter(a1)), a1);
20203 return true;
20204 }
20205
20206 case MSGC_CTRUPPC:
20207 case MSGC_CTRDNPC:
20208 case MSGC_CTRSETPC:
20209 {
20210 2 int32_t code = MsgStrings[msgstr].s[msgptr]-1;
20211 2 int32_t counter = grab_next_argument();
20212 2 int32_t amount = grab_next_argument();
20213 2 amount = int32_t(vbound(amount*0.01, 0.0, 1.0)*game->get_maxcounter(counter));
20214
20215
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(code==MSGC_CTRDNPC)
20216 amount*=-1;
20217
20218
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if(code==MSGC_CTRSETPC)
20219 game->set_counter(amount, counter);
20220 else
20221 2 game->change_counter(amount, counter);
20222
20223 2 return true;
20224 }
20225
20226 case MSGC_GIVEITEM:
20227 {
20228 68 int32_t itemID = grab_next_argument();
20229
20230 68 getitem(itemID, true);
20231
2/4
✓ Branch 0 taken 68 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 68 times.
68 if ( !FFCore.doscript(ScriptType::Item, itemID) && (((unsigned)itemID) < 256) )
20232 {
20233 68 FFCore.reset_script_engine_data(ScriptType::Item, itemID);
20234 68 FFCore.doscript(ScriptType::Item, itemID) = (itemsbuf[itemID].flags&item_passive_script) > 0;
20235 68 }
20236 68 return true;
20237 }
20238
20239
20240 case MSGC_WARP:
20241 {
20242 int32_t dmap = grab_next_argument();
20243 int32_t scrn = grab_next_argument();
20244 int32_t dx = grab_next_argument();
20245 int32_t dy = grab_next_argument();
20246 int32_t wfx = grab_next_argument();
20247 int32_t sfx = grab_next_argument();
20248 if(dx >= MAX_SCC_ARG) dx = -1;
20249 if(dy >= MAX_SCC_ARG) dy = -1;
20250 FFCore.warp_player(wtIWARP, dmap, scrn, dx, dy, wfx, sfx, 0, 0);
20251 do_end_str = true;
20252 return true;
20253 }
20254
20255 case MSGC_SETSCREEND:
20256 {
20257 int32_t dmap = (grab_next_argument()<<7); //dmap and screen may be transposed here.
20258 int32_t screen = grab_next_argument();
20259 int32_t reg = grab_next_argument();
20260 int32_t val = grab_next_argument();
20261 FFCore.set_screen_d(screen + dmap, reg, val);
20262 return true;
20263 }
20264 case MSGC_TAKEITEM:
20265 {
20266 9 int32_t itemID = grab_next_argument();
20267
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if ( FFCore.doscript(ScriptType::Item, itemID) )
20268 {
20269 FFCore.doscript(ScriptType::Item, itemID) = 4; //Val of 4 means 'clear stack and quit'
20270 }
20271 9 takeitem(itemID);
20272
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if ( game->forced_bwpn == itemID )
20273 {
20274 game->forced_bwpn = -1;
20275 } //not else if! -Z
20276
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if ( game->forced_awpn == itemID )
20277 {
20278 game->forced_awpn = -1;
20279 }
20280
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if ( game->forced_xwpn == itemID )
20281 {
20282 game->forced_xwpn = -1;
20283 } //not else if! -Z
20284
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if ( game->forced_ywpn == itemID )
20285 {
20286 game->forced_ywpn = -1;
20287 }
20288 9 verifyBothWeapons();
20289 9 return true;
20290 }
20291
20292 case MSGC_SFX:
20293 {
20294 17 sfx((int32_t)grab_next_argument(),128);
20295 17 return true;
20296 }
20297
20298 case MSGC_MIDI:
20299 {
20300 7 int32_t music = (int32_t)(grab_next_argument());
20301
20302
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 1 times.
7 if(music==0)
20303 1 music_stop();
20304 else
20305 6 jukebox(music+(ZC_MIDI_COUNT-1));
20306
20307 7 return true;
20308 }
20309
20310 case MSGC_NAME:
20311 {
20312 6 doing_name_insert = true;
20313 6 sprintf(namebuf, "%s", game->get_name());
20314 6 nameptr = namebuf;
20315 6 return true;
20316 }
20317
20318 case MSGC_FONT:
20319 {
20320 int fontid = grab_next_argument();
20321 int oh = text_height(msgfont);
20322 msgfont = get_zc_font(fontid);
20323 int nh = text_height(msgfont);
20324 int mh = std::max(oh,nh);
20325 if(mh > ssc_tile_hei_buf)
20326 ssc_tile_hei_buf = mh;
20327 return true;
20328 }
20329 case MSGC_RUN_FRZ_GENSCR:
20330 {
20331 word scr_id = grab_next_argument();
20332 bool force_redraw = grab_next_argument()!=0;
20333 if(force_redraw)
20334 {
20335 update_msgstr();
20336 draw_screen(tmpscr);
20337 }
20338 FFCore.runGenericFrozenEngine(scr_id);
20339 return true;
20340 }
20341 case MSGC_DRAWTILE:
20342 {
20343 int32_t tl = grab_next_argument();
20344 int32_t cs = grab_next_argument();
20345 int32_t t_wid = grab_next_argument();
20346 int32_t t_hei = grab_next_argument();
20347 int32_t fl = grab_next_argument();
20348
20349 if(cursor_x+MsgStrings[msgstr].hspace + t_wid > msg_w-msg_margins[right])
20350 {
20351 ssc_tile_hei = ssc_tile_hei_buf;
20352 int32_t thei = zc_max(ssc_tile_hei, text_height(msgfont));
20353 ssc_tile_hei_buf = -1;
20354 cursor_y += thei + MsgStrings[msgstr].vspace;
20355 if(bottom_margin_clip()) return true;
20356 cursor_x=msg_margins[left];
20357 }
20358
20359 overtileblock16(msg_txt_bmp_buf, tl, cursor_x, cursor_y, (int32_t)ceil(t_wid/16.0), (int32_t)ceil(t_hei/16.0), cs, fl);
20360 ssc_tile_hei_buf = zc_max(ssc_tile_hei_buf, t_hei);
20361 cursor_x += MsgStrings[msgstr].hspace + t_wid;
20362 return true;
20363 }
20364
20365 case MSGC_GOTOIFRAND:
20366 {
20367 int32_t odds = (int32_t)(grab_next_argument());
20368
20369 if(!odds || !(zc_oldrand()%odds))
20370 goto switched;
20371
20372 (void)grab_next_argument();
20373 return true;
20374 }
20375
20376 case MSGC_GOTOIFGLOBAL:
20377 {
20378 int32_t arg = (int32_t)grab_next_argument();
20379 int32_t d = zc_min(7,arg);
20380 int32_t s = ((get_currdmap())<<7) + get_currscr()-(DMaps[get_currdmap()].type==dmOVERW ? 0 : DMaps[get_currdmap()].xoff);
20381 arg = (int32_t)grab_next_argument();
20382
20383 if(game->screen_d[s][d] >= arg)
20384 goto switched;
20385
20386 (void)grab_next_argument();
20387 return true;
20388 }
20389
20390 case MSGC_CHANGEPORTRAIT:
20391 {
20392 return true; //not implemented
20393 }
20394
20395 case MSGC_GOTOIFCREEND:
20396 {
20397 int32_t dmap = (grab_next_argument()<<7); //dmap and screen may be transposed here.
20398 int32_t screen = grab_next_argument();
20399 int32_t reg = grab_next_argument();
20400 int32_t val = grab_next_argument();
20401 //int32_t nxtstr = grab_next_argument();
20402 if ( FFCore.get_screen_d(screen + dmap, reg) >= val )
20403 {
20404 goto switched;
20405 }
20406 (void)grab_next_argument();
20407 return true;
20408 }
20409
20410 case MSGC_GOTOIF:
20411 {
20412 122 int32_t it = (int32_t)grab_next_argument();
20413
20414
3/4
✓ Branch 0 taken 122 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 87 times.
✓ Branch 3 taken 35 times.
122 if(unsigned(it)<MAXITEMS && game->item[it])
20415 35 goto switched;
20416
20417 87 (void)grab_next_argument();
20418 87 return true;
20419 }
20420
20421 case MSGC_GOTOIFCTR:
20422 {
20423
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 6 times.
13 if(game->get_counter(grab_next_argument())>=grab_next_argument())
20424 7 goto switched;
20425
20426 6 (void)grab_next_argument();
20427 6 return true;
20428 }
20429
20430 case MSGC_GOTOIFCTRPC:
20431 {
20432 int32_t counter = grab_next_argument();
20433 int32_t amount = (int32_t)(((grab_next_argument())/100)*game->get_maxcounter(counter));
20434
20435 if(game->get_counter(counter)>=amount)
20436 goto switched;
20437
20438 (void)grab_next_argument();
20439 return true;
20440 }
20441
20442 case MSGC_GOTOIFTRICOUNT:
20443 {
20444 if(TriforceCount() >= (int32_t)(grab_next_argument()))
20445 goto switched;
20446
20447 (void)grab_next_argument();
20448 return true;
20449 }
20450
20451 case MSGC_GOTOIFTRI:
20452 {
20453 int32_t lev = (int32_t)(grab_next_argument());
20454
20455 if(lev<MAXLEVELS && game->lvlitems[lev]&liTRIFORCE)
20456 goto switched;
20457
20458 (void)grab_next_argument();
20459 return true;
20460 }
20461
20462 case MSGC_SETUPMENU:
20463 {
20464 2 msg_menu_data[MNU_CURSOR_TILE] = grab_next_argument();
20465 2 msg_menu_data[MNU_CURSOR_CSET] = grab_next_argument();
20466 2 msg_menu_data[MNU_CURSOR_WID] = grab_next_argument();
20467 2 msg_menu_data[MNU_CURSOR_HEI] = grab_next_argument();
20468 2 msg_menu_data[MNU_CURSOR_FLIP] = grab_next_argument();
20469 2 return true;
20470 }
20471
20472 case MSGC_MENUCHOICE:
20473 {
20474 8 int32_t pos = grab_next_argument();
20475 8 int32_t upos = grab_next_argument();
20476 8 int32_t dpos = grab_next_argument();
20477 8 int32_t lpos = grab_next_argument();
20478 8 int32_t rpos = grab_next_argument();
20479
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 2 times.
8 if(cursor_x+MsgStrings[msgstr].hspace + msg_menu_data[MNU_CURSOR_WID] > msg_w-msg_margins[right])
20480 {
20481 2 ssc_tile_hei = ssc_tile_hei_buf;
20482
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 int32_t thei = zc_max(ssc_tile_hei, text_height(msgfont));
20483 2 ssc_tile_hei_buf = -1;
20484 2 cursor_y += thei + MsgStrings[msgstr].vspace;
20485
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if(bottom_margin_clip()) break;
20486 2 cursor_x=msg_margins[left];
20487 2 }
20488
20489 16 menu_options[pos] = menu_choice(cursor_x, cursor_y, pos,
20490 8 upos, dpos, lpos, rpos);
20491
20492
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 4 times.
8 ssc_tile_hei_buf = zc_max(ssc_tile_hei_buf, msg_menu_data[MNU_CURSOR_HEI]);
20493 8 cursor_x += MsgStrings[msgstr].hspace + msg_menu_data[MNU_CURSOR_WID];
20494 8 return true;
20495 }
20496
20497 case MSGC_RUNMENU:
20498 {
20499 2 msg_menu_data[MNU_CHOSEN] = 0;
20500 2 msg_menu_data[MNU_CAN_CONFIRM] = 0;
20501
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if(menu_options.size() < 1)
20502 return true;
20503 2 do_run_menu = true;
20504 2 return true;
20505 }
20506
20507 case MSGC_GOTOMENUCHOICE:
20508 {
20509 4 int32_t choice = grab_next_argument();
20510
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 2 times.
4 if(msg_menu_data[MNU_CHOSEN] == choice)
20511 2 goto switched;
20512 2 (void)grab_next_argument();
20513 2 return true;
20514 }
20515
20516 case MSGC_ENDSTRING:
20517 {
20518 1 do_end_str = true;
20519 1 return true;
20520 }
20521 case MSGC_WAIT_ADVANCE:
20522 {
20523 wait_advance = true;
20524 linkedmsgclk = 51;
20525 return true;
20526 }
20527 case MSGC_TRIGSECRETS:
20528 {
20529 bool perm = (bool)grab_next_argument();
20530 hidden_entrance(0, true, false, -8);
20531 if(perm)
20532 setmapflag(mSECRET);
20533 return true;
20534 }
20535 case MSGC_TRIG_CMB_COPYCAT:
20536 {
20537 int copy_id = (int)grab_next_argument();
20538 if(copy_id == byte(copy_id))
20539 trig_copycat(copy_id);
20540 return true;
20541 }
20542 case MSGC_SETSCREENSTATE:
20543 {
20544 int32_t flag = int32_t(grab_next_argument());
20545 if(unsigned(flag)>=mMAXIND)
20546 {
20547 Z_error("SCC 133: Flag %d is invalid\n", flag);
20548 return true;
20549 }
20550 bool state = bool(grab_next_argument());
20551 if(state)
20552 setmapflag(1<<flag);
20553 else
20554 unsetmapflag(1<<flag,true);
20555 return true;
20556 }
20557 case MSGC_SETSCREENSTATER:
20558 {
20559 int32_t map = (int32_t)grab_next_argument();
20560 int32_t scrid = (int32_t)grab_next_argument();
20561 if(map < 1 || map > map_count)
20562 {
20563 Z_error("SCC 134: Map %d is invalid\n", map);
20564 return true;
20565 }
20566 if(unsigned(scrid)>=0x80)
20567 {
20568 Z_error("SCC 134: Screen %d is invalid\n", scrid);
20569 return true;
20570 }
20571
20572 int32_t flag = int32_t(grab_next_argument());
20573 if(unsigned(flag)>=mMAXIND)
20574 {
20575 Z_error("SCC 134: Flag %d is invalid\n", flag);
20576 return true;
20577 }
20578 bool state = bool(grab_next_argument());
20579 if(state)
20580 setmapflag(mapind(map,scrid),1<<flag);
20581 else
20582 unsetmapflag(mapind(map,scrid),1<<flag,true);
20583 return true;
20584 }
20585 switched:
20586 44 int32_t lev = (int32_t)(grab_next_argument());
20587
2/4
✓ Branch 0 taken 44 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 13 times.
✗ Branch 3 not taken.
44 if(lev && get_qr(qr_SCC_GOTO_RESPECTS_CONTFLAG)
20588
2/2
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 31 times.
44 && (MsgStrings[lev].stringflags & STRINGFLAG_CONT))
20589 {
20590 msgstr=lev;
20591 msgpos=msgptr=0;
20592 msgfont=setmsgfont();
20593 }
20594 else
20595 {
20596 44 donewmsg(lev);
20597 44 ssc_tile_hei_buf = -1;
20598 }
20599 44 msgptr--; // To counteract it being incremented after this routine is called.
20600 44 putprices(false);
20601 44 return true;
20602 }
20603
20604 237259 return false;
20605 242981 }
20606
20607 // Wraps the message string... probably.
20608 233741 void wrapmsgstr(char *s3)
20609 {
20610 233741 int32_t j=0;
20611
20612
2/2
✓ Branch 0 taken 23941 times.
✓ Branch 1 taken 209800 times.
233741 if(MsgStrings[msgstr].stringflags & STRINGFLAG_WRAP)
20613 {
20614
2/2
✓ Branch 0 taken 4767 times.
✓ Branch 1 taken 19174 times.
23941 if(msgspace)
20615 {
20616 4767 char c = MsgStrings[msgstr].s[msgptr];
20617
4/6
✓ Branch 0 taken 4440 times.
✓ Branch 1 taken 327 times.
✓ Branch 2 taken 4440 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4440 times.
✗ Branch 5 not taken.
4767 if(c != ' ' && c >= 32 && c <= 126)
20618 {
20619
4/4
✓ Branch 0 taken 122 times.
✓ Branch 1 taken 24450 times.
✓ Branch 2 taken 20132 times.
✓ Branch 3 taken 4440 times.
24572 for(int32_t k=0; MsgStrings[msgstr].s[msgptr+k] && MsgStrings[msgstr].s[msgptr+k] != ' '; k++)
20620 {
20621
3/4
✓ Branch 0 taken 19569 times.
✓ Branch 1 taken 563 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 19569 times.
20132 if(MsgStrings[msgstr].s[msgptr+k] >= 32 && MsgStrings[msgstr].s[msgptr+k] <= 126) s3[j++] = MsgStrings[msgstr].s[msgptr+k];
20622 20132 }
20623
20624 4440 s3[j] = 0;
20625 4440 msgspace = false;
20626 4440 }
20627 else
20628 {
20629 327 s3[0] = c;
20630 327 s3[1] = 0;
20631 }
20632 4767 }
20633 else
20634 {
20635 19174 s3[0] = MsgStrings[msgstr].s[msgptr];
20636 19174 s3[1] = 0;
20637
20638
2/2
✓ Branch 0 taken 15129 times.
✓ Branch 1 taken 4045 times.
19174 if(s3[0] == ' ') msgspace=true;
20639 }
20640 23941 }
20641 else
20642 {
20643 209800 s3[0] = MsgStrings[msgstr].s[msgptr];
20644 209800 s3[1] = 0;
20645 }
20646 233741 }
20647
20648 // Returns true if the pointer is at a string's
20649 // null terminator or a trailing space
20650 805686 bool atend(char const* str)
20651 {
20652 805686 int32_t i=0;
20653
20654
2/2
✓ Branch 0 taken 6343123 times.
✓ Branch 1 taken 805686 times.
7148809 while(str[i]==' ')
20655 6343123 i++;
20656
20657 805686 return str[i]=='\0';
20658 }
20659
20660 14449452 void putmsg()
20661 {
20662 14449452 bool oldmargin = get_qr(qr_OLD_STRING_EDITOR_MARGINS)!=0;
20663
2/2
✓ Branch 0 taken 668908 times.
✓ Branch 1 taken 13780544 times.
14449452 if(!msgorig) msgorig=msgstr;
20664
20665
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 14449452 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
14449452 if(wait_advance && linkedmsgclk < 1)
20666 linkedmsgclk = 1;
20667
2/2
✓ Branch 0 taken 14176769 times.
✓ Branch 1 taken 272683 times.
14449452 if(linkedmsgclk>0)
20668 {
20669
2/2
✓ Branch 0 taken 126232 times.
✓ Branch 1 taken 146451 times.
272683 if(linkedmsgclk==1)
20670 {
20671
6/6
✓ Branch 0 taken 126231 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 123411 times.
✓ Branch 3 taken 2820 times.
✓ Branch 4 taken 108 times.
✓ Branch 5 taken 123303 times.
126232 if(do_end_str||cAbtn()||cBbtn())
20672 {
20673 2929 do_end_str = false;
20674 2929 linkedmsgclk = 0;
20675
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2929 times.
2929 if(wait_advance)
20676 {
20677 wait_advance = false;
20678 }
20679 else
20680 {
20681 2929 msgstr=MsgStrings[msgstr].nextstring;
20682 2929 ssc_tile_hei_buf = -1;
20683
3/4
✓ Branch 0 taken 943 times.
✓ Branch 1 taken 1986 times.
✓ Branch 2 taken 943 times.
✗ Branch 3 not taken.
2929 if(!msgstr && enqueued_str)
20684 {
20685 msgstr = enqueued_str;
20686 enqueued_str = 0;
20687 }
20688
2/2
✓ Branch 0 taken 1986 times.
✓ Branch 1 taken 943 times.
2929 if(!msgstr)
20689 {
20690 943 msgfont=get_zc_font(font_zfont);
20691
20692
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 939 times.
943 if(tmpscr->room!=rGRUMBLE)
20693 939 blockpath=false;
20694
20695 943 dismissmsg();
20696 943 goto disappear;
20697 }
20698
20699 1986 donewmsg(msgstr);
20700 1986 putprices(false);
20701 }
20702 1986 }
20703 125289 }
20704 else
20705 {
20706 146451 --linkedmsgclk;
20707 }
20708 271740 }
20709
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14448509 times.
14448509 if(wait_advance) return; //Waiting for buttonpress
20710
20711
10/10
✓ Branch 0 taken 14446196 times.
✓ Branch 1 taken 2313 times.
✓ Branch 2 taken 663737 times.
✓ Branch 3 taken 13782459 times.
✓ Branch 4 taken 527084 times.
✓ Branch 5 taken 136653 times.
✓ Branch 6 taken 263640 times.
✓ Branch 7 taken 263444 times.
✓ Branch 8 taken 854 times.
✓ Branch 9 taken 262786 times.
14448509 if(!do_run_menu && (!msgstr || msgpos>=10000 || msgptr>=MsgStrings[msgstr].s.size() || bottom_margin_clip()))
20712 {
20713
2/2
✓ Branch 0 taken 400951 times.
✓ Branch 1 taken 13782459 times.
14183410 if(!msgstr)
20714 13782459 msgorig=0;
20715
20716 14183410 msg_active = false;
20717 14183410 return;
20718 }
20719
20720 265099 msg_onscreen = true; // Now the message is onscreen (see donewmsg()).
20721
20722 char s3[145];
20723 int32_t tlength;
20724
20725 // Bypass the string with the B button!
20726
4/4
✓ Branch 0 taken 1343 times.
✓ Branch 1 taken 263756 times.
✓ Branch 2 taken 1240 times.
✓ Branch 3 taken 262516 times.
265099 if(((cBbtn())&&(get_qr(qr_ALLOWMSGBYPASS))) || msgspeed==0)
20727 {
20728 //finish writing out the string
20729
4/4
✓ Branch 0 taken 103 times.
✓ Branch 1 taken 79061 times.
✓ Branch 2 taken 1232 times.
✓ Branch 3 taken 77932 times.
80514 while(msgptr<MsgStrings[msgstr].s.size() && !atend(MsgStrings[msgstr].s.c_str()+msgptr))
20730 {
20731
5/6
✓ Branch 0 taken 18708 times.
✓ Branch 1 taken 59224 times.
✓ Branch 2 taken 18707 times.
✓ Branch 3 taken 1 times.
✓ Branch 4 taken 18707 times.
✗ Branch 5 not taken.
77932 if(msgspeed && !(cBbtn() && get_qr(qr_ALLOWMSGBYPASS)))
20732 1 goto breakout; // break out if message speed was changed to non-zero
20733
4/6
✓ Branch 0 taken 77931 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 77931 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 285 times.
✓ Branch 5 taken 77646 times.
77931 else if(!do_run_menu && !doing_name_insert && !parsemsgcode())
20734 {
20735
1/2
✓ Branch 0 taken 77646 times.
✗ Branch 1 not taken.
77646 if(bottom_margin_clip())
20736 break;
20737
20738 77646 wrapmsgstr(s3);
20739
20740
2/2
✓ Branch 0 taken 20449 times.
✓ Branch 1 taken 57197 times.
77646 if(MsgStrings[msgstr].s[msgptr]==' ')
20741 {
20742 20449 tlength = msgfont->vtable->char_length(msgfont, MsgStrings[msgstr].s[msgptr]) + MsgStrings[msgstr].hspace;
20743
20744
2/2
✓ Branch 0 taken 47 times.
✓ Branch 1 taken 1347 times.
21843 if(cursor_x+tlength > (msg_w-msg_margins[right])
20745
5/6
✓ Branch 0 taken 1394 times.
✓ Branch 1 taken 19055 times.
✓ Branch 2 taken 1394 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1300 times.
✓ Branch 5 taken 47 times.
20449 && ((cursor_x > (msg_w-msg_margins[right]) || !(MsgStrings[msgstr].stringflags & STRINGFLAG_WRAP))
20746 47 ? true : strcmp(s3," ")!=0))
20747 {
20748 1347 ssc_tile_hei = ssc_tile_hei_buf;
20749
1/2
✓ Branch 0 taken 1347 times.
✗ Branch 1 not taken.
1347 int32_t thei = zc_max(ssc_tile_hei, text_height(msgfont));
20750 1347 ssc_tile_hei_buf = -1;
20751 1347 cursor_y += thei + MsgStrings[msgstr].vspace;
20752
1/2
✓ Branch 0 taken 1347 times.
✗ Branch 1 not taken.
1347 if(bottom_margin_clip()) break;
20753 1347 cursor_x=msg_margins[left];
20754 1347 }
20755
20756 20449 char buf[2] = {0};
20757 20449 sprintf(buf,"%c",MsgStrings[msgstr].s[msgptr]);
20758
20759 20449 textout_styled_aligned_ex(msg_txt_bmp_buf,msgfont,buf,cursor_x,cursor_y,msg_shdtype,sstaLEFT,msgcolour,msg_shdcol,-1);
20760
20761 20449 cursor_x+=tlength;
20762 20449 }
20763 else
20764 {
20765 57197 tlength = text_length(msgfont, s3) + ((int32_t)strlen(s3)*MsgStrings[msgstr].hspace);
20766
2/2
✓ Branch 0 taken 190 times.
✓ Branch 1 taken 536 times.
57923 if(cursor_x+tlength > (msg_w-msg_margins[right])
20767
5/6
✓ Branch 0 taken 773 times.
✓ Branch 1 taken 56424 times.
✓ Branch 2 taken 726 times.
✓ Branch 3 taken 47 times.
✓ Branch 4 taken 583 times.
✗ Branch 5 not taken.
57197 && ((cursor_x > (msg_w-msg_margins[right]) || !(MsgStrings[msgstr].stringflags & STRINGFLAG_WRAP))
20768 190 ? true : strcmp(s3," ")!=0))
20769 {
20770 773 ssc_tile_hei = ssc_tile_hei_buf;
20771
1/2
✓ Branch 0 taken 773 times.
✗ Branch 1 not taken.
773 int32_t thei = zc_max(ssc_tile_hei, text_height(msgfont));
20772 773 ssc_tile_hei_buf = -1;
20773 773 cursor_y += thei + MsgStrings[msgstr].vspace;
20774
1/2
✓ Branch 0 taken 773 times.
✗ Branch 1 not taken.
773 if(bottom_margin_clip()) break;
20775 773 cursor_x=msg_margins[left];
20776 773 }
20777
20778 57197 sfx(MsgStrings[msgstr].sfx);
20779
20780 57197 char buf[2] = {0};
20781 57197 sprintf(buf,"%c",MsgStrings[msgstr].s[msgptr]);
20782
20783 57197 textout_styled_aligned_ex(msg_txt_bmp_buf,msgfont,buf,cursor_x,cursor_y,msg_shdtype,sstaLEFT,msgcolour,msg_shdcol,-1);
20784
20785 57197 cursor_x += msgfont->vtable->char_length(msgfont, MsgStrings[msgstr].s[msgptr]);
20786 57197 cursor_x += MsgStrings[msgstr].hspace;
20787 }
20788
20789 77646 msgpos++;
20790 77646 }
20791
1/2
✓ Branch 0 taken 77931 times.
✗ Branch 1 not taken.
77931 if(do_run_menu)
20792 {
20793 if(runMenuCursor())
20794 {
20795 do_run_menu = false;
20796 }
20797 else break;
20798 }
20799
1/2
✓ Branch 0 taken 77931 times.
✗ Branch 1 not taken.
77931 if(doing_name_insert)
20800 {
20801 if(*nameptr)
20802 {
20803 if(bottom_margin_clip())
20804 break;
20805
20806 char s3[9] = {0};
20807
20808 if(MsgStrings[msgstr].stringflags & STRINGFLAG_WRAP)
20809 {
20810 strcpy(s3, nameptr);
20811 }
20812 else
20813 {
20814 s3[0] = *nameptr;
20815 s3[1] = 0;
20816 }
20817
20818 tlength = text_length(msgfont, s3) + ((int32_t)strlen(s3)*MsgStrings[msgstr].hspace);
20819
20820 if(cursor_x+tlength > (msg_w-msg_margins[right])
20821 && ((cursor_x > (msg_w-msg_margins[right]) || !(MsgStrings[msgstr].stringflags & STRINGFLAG_WRAP))
20822 ? true : strcmp(s3," ")!=0))
20823 {
20824 ssc_tile_hei = ssc_tile_hei_buf;
20825 int32_t thei = zc_max(ssc_tile_hei, text_height(msgfont));
20826 ssc_tile_hei_buf = -1;
20827 cursor_y += thei + MsgStrings[msgstr].vspace;
20828 if(bottom_margin_clip()) break;
20829 cursor_x=msg_margins[left];
20830 }
20831
20832 sfx(MsgStrings[msgstr].sfx);
20833
20834 char buf[2] = {0};
20835 sprintf(buf,"%c",*nameptr);
20836
20837 textout_styled_aligned_ex(msg_txt_bmp_buf,msgfont,buf,cursor_x,cursor_y,msg_shdtype,sstaLEFT,msgcolour,msg_shdcol,-1);
20838
20839 cursor_x += msgfont->vtable->char_length(msgfont, *nameptr);
20840 cursor_x += MsgStrings[msgstr].hspace;
20841 ++nameptr;
20842 continue; //don't advance the msgptr, as the next char in it was not processed!
20843 }
20844 else doing_name_insert = false;
20845 }
20846 77931 ++msgptr;
20847
1/2
✓ Branch 0 taken 77931 times.
✗ Branch 1 not taken.
77931 if(do_end_str)
20848 goto strendcheck;
20849
1/2
✓ Branch 0 taken 77931 times.
✗ Branch 1 not taken.
77931 if(wait_advance)
20850 return;
20851
2/2
✓ Branch 0 taken 76718 times.
✓ Branch 1 taken 1213 times.
77931 if(atend(MsgStrings[msgstr].s.c_str()+msgptr))
20852 {
20853
2/2
✓ Branch 0 taken 427 times.
✓ Branch 1 taken 786 times.
1213 if(MsgStrings[msgstr].nextstring)
20854 {
20855
1/2
✓ Branch 0 taken 786 times.
✗ Branch 1 not taken.
786 if(MsgStrings[MsgStrings[msgstr].nextstring].stringflags & STRINGFLAG_CONT)
20856 {
20857 msgstr=MsgStrings[msgstr].nextstring;
20858 msgpos=msgptr=0;
20859 msgfont=setmsgfont();
20860 }
20861 786 }
20862 1213 }
20863 }
20864
20865
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1232 times.
1232 if (!do_run_menu)
20866 {
20867 1232 msgclk = 72;
20868 1232 msgpos = 10000;
20869 1232 }
20870 1232 }
20871 else
20872 262516 {
20873 breakout:
20874 262517 word tempspeed = msgspeed;
20875
2/2
✓ Branch 0 taken 261554 times.
✓ Branch 1 taken 963 times.
262517 if (do_run_menu)
20876 963 tempspeed = 0;
20877
6/6
✓ Branch 0 taken 210795 times.
✓ Branch 1 taken 51722 times.
✓ Branch 2 taken 120294 times.
✓ Branch 3 taken 90501 times.
✓ Branch 4 taken 113455 times.
✓ Branch 5 taken 6839 times.
262517 if(((msgclk++)%(tempspeed+1)<tempspeed)&&((!cAbtn())||(!get_qr(qr_ALLOWFASTMSG))))
20878 97340 return;
20879 }
20880
20881 // Start writing the string
20882
2/2
✓ Branch 0 taken 163526 times.
✓ Branch 1 taken 2883 times.
169292 if(msgptr == 0)
20883 {
20884
2/2
✓ Branch 0 taken 2883 times.
✓ Branch 1 taken 5068 times.
7951 while(MsgStrings[msgstr].s[msgptr]==' ')
20885 {
20886 5068 tlength = msgfont->vtable->char_length(msgfont, MsgStrings[msgstr].s[msgptr]) + MsgStrings[msgstr].hspace;
20887
20888
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
5156 if(cursor_x+tlength > (msg_w-msg_margins[right])
20889
4/6
✓ Branch 0 taken 4980 times.
✓ Branch 1 taken 88 times.
✓ Branch 2 taken 88 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 88 times.
✗ Branch 5 not taken.
5068 && ((cursor_x > (msg_w-msg_margins[right]) || !(MsgStrings[msgstr].stringflags & STRINGFLAG_WRAP))
20890 ? 1 : strcmp(s3," ")!=0))
20891 {
20892 88 ssc_tile_hei = ssc_tile_hei_buf;
20893
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 int32_t thei = zc_max(ssc_tile_hei, text_height(msgfont));
20894 88 ssc_tile_hei_buf = -1;
20895 88 cursor_y += thei + MsgStrings[msgstr].vspace;
20896
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 if(bottom_margin_clip()) break;
20897 88 cursor_x=msg_margins[left];
20898 88 }
20899
20900 5068 cursor_x+=tlength;
20901 5068 ++msgptr;
20902 5068 ++msgpos;
20903
20904 // The "Continue From Previous" feature
20905
2/2
✓ Branch 0 taken 3700 times.
✓ Branch 1 taken 1368 times.
5068 if(atend(MsgStrings[msgstr].s.c_str()+msgptr))
20906 {
20907
1/2
✓ Branch 0 taken 1368 times.
✗ Branch 1 not taken.
1368 if(MsgStrings[msgstr].nextstring)
20908 {
20909 if(MsgStrings[MsgStrings[msgstr].nextstring].stringflags & STRINGFLAG_CONT)
20910 {
20911 msgstr=MsgStrings[msgstr].nextstring;
20912 msgpos=msgptr=0;
20913 msgfont=setmsgfont();
20914 }
20915 }
20916 1368 }
20917 }
20918 2883 }
20919
20920 reparsesinglechar:
20921 // Continue printing the string!
20922
3/4
✓ Branch 0 taken 159832 times.
✓ Branch 1 taken 6579 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 159832 times.
326240 if(!atend(MsgStrings[msgstr].s.c_str()+msgptr) && !bottom_margin_clip())
20923 {
20924
6/6
✓ Branch 0 taken 158869 times.
✓ Branch 1 taken 963 times.
✓ Branch 2 taken 158845 times.
✓ Branch 3 taken 24 times.
✓ Branch 4 taken 2750 times.
✓ Branch 5 taken 156095 times.
159832 if(!do_run_menu && !doing_name_insert && !parsemsgcode())
20925 {
20926 156095 wrapmsgstr(s3);
20927
20928 156095 tlength = text_length(msgfont, s3) + ((int32_t)strlen(s3)*MsgStrings[msgstr].hspace);
20929
20930
2/2
✓ Branch 0 taken 256 times.
✓ Branch 1 taken 1867 times.
158218 if(cursor_x+tlength > (msg_w-msg_margins[right])
20931
6/6
✓ Branch 0 taken 2166 times.
✓ Branch 1 taken 153929 times.
✓ Branch 2 taken 2123 times.
✓ Branch 3 taken 43 times.
✓ Branch 4 taken 1867 times.
✓ Branch 5 taken 43 times.
156095 && ((cursor_x > (msg_w-msg_margins[right]) || !(MsgStrings[msgstr].stringflags & STRINGFLAG_WRAP))
20932 256 ? true : strcmp(s3," ")!=0))
20933 {
20934 2123 ssc_tile_hei = ssc_tile_hei_buf;
20935
1/2
✓ Branch 0 taken 2123 times.
✗ Branch 1 not taken.
2123 int32_t thei = zc_max(ssc_tile_hei, text_height(msgfont));
20936 2123 ssc_tile_hei_buf = -1;
20937 2123 cursor_y += thei + MsgStrings[msgstr].vspace;
20938
1/2
✓ Branch 0 taken 2123 times.
✗ Branch 1 not taken.
2123 if(bottom_margin_clip()) goto strendcheck;
20939 2123 cursor_x=msg_margins[left];
20940 //if(space) s3[0]=0;
20941 2123 }
20942
20943 156095 sfx(MsgStrings[msgstr].sfx);
20944
20945 156095 char buf[2] = {0};
20946 156095 sprintf(buf,"%c",MsgStrings[msgstr].s[msgptr]);
20947
20948 156095 textout_styled_aligned_ex(msg_txt_bmp_buf,msgfont,buf,cursor_x,cursor_y,msg_shdtype,sstaLEFT,msgcolour,msg_shdcol,-1);
20949
20950 156095 cursor_x += msgfont->vtable->char_length(msgfont, MsgStrings[msgstr].s[msgptr]);
20951 156095 cursor_x += MsgStrings[msgstr].hspace;
20952 156095 msgpos++;
20953 156095 }
20954
2/2
✓ Branch 0 taken 159831 times.
✓ Branch 1 taken 1 times.
159832 if(do_end_str)
20955 1 goto strendcheck;
20956
1/2
✓ Branch 0 taken 159831 times.
✗ Branch 1 not taken.
159831 if(wait_advance)
20957 {
20958 ++msgptr;
20959 return;
20960 }
20961
2/2
✓ Branch 0 taken 965 times.
✓ Branch 1 taken 158866 times.
159831 else if(do_run_menu)
20962 {
20963
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 963 times.
965 if(runMenuCursor())
20964 {
20965 2 do_run_menu = false;
20966 2 ++msgptr;
20967 2 goto reparsesinglechar;
20968 }
20969 963 }
20970
4/4
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 158836 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 24 times.
158866 else if(doing_name_insert && *nameptr)
20971 {
20972 24 char s3[9] = {0};
20973
20974
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if(MsgStrings[msgstr].stringflags & STRINGFLAG_WRAP)
20975 {
20976 24 strcpy(s3, nameptr);
20977 24 }
20978 else
20979 {
20980 s3[0] = *nameptr;
20981 s3[1] = 0;
20982 }
20983
20984 24 tlength = text_length(msgfont, s3) + ((int32_t)strlen(s3)*MsgStrings[msgstr].hspace);
20985
20986
0/2
✗ Branch 0 not taken.
✗ Branch 1 not taken.
24 if(cursor_x+tlength > (msg_w-msg_margins[right])
20987
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 24 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
24 && ((cursor_x > (msg_w-msg_margins[right]) || !(MsgStrings[msgstr].stringflags & STRINGFLAG_WRAP))
20988 ? true : strcmp(s3," ")!=0))
20989 {
20990 ssc_tile_hei = ssc_tile_hei_buf;
20991 int32_t thei = zc_max(ssc_tile_hei, text_height(msgfont));
20992 ssc_tile_hei_buf = -1;
20993 cursor_y += thei + MsgStrings[msgstr].vspace;
20994 if(bottom_margin_clip()) goto strendcheck;
20995 cursor_x=msg_margins[left];
20996 }
20997
20998 24 sfx(MsgStrings[msgstr].sfx);
20999
21000 24 char buf[2] = {0};
21001 24 sprintf(buf,"%c",*nameptr);
21002
21003 24 textout_styled_aligned_ex(msg_txt_bmp_buf,msgfont,buf,cursor_x,cursor_y,msg_shdtype,sstaLEFT,msgcolour,msg_shdcol,-1);
21004
21005 24 cursor_x += msgfont->vtable->char_length(msgfont, *nameptr);
21006 24 cursor_x += MsgStrings[msgstr].hspace;
21007 24 ++nameptr;
21008 24 }
21009 else
21010 {
21011 158842 doing_name_insert = false;
21012 158842 msgptr++;
21013
21014
2/2
✓ Branch 0 taken 156149 times.
✓ Branch 1 taken 2693 times.
158842 if(atend(MsgStrings[msgstr].s.c_str()+msgptr))
21015 {
21016
2/2
✓ Branch 0 taken 1492 times.
✓ Branch 1 taken 1201 times.
2693 if(MsgStrings[msgstr].nextstring)
21017 {
21018
1/2
✓ Branch 0 taken 1201 times.
✗ Branch 1 not taken.
1201 if(MsgStrings[MsgStrings[msgstr].nextstring].stringflags & STRINGFLAG_CONT)
21019 {
21020 msgstr=MsgStrings[msgstr].nextstring;
21021 msgpos=msgptr=0;
21022 msgfont=setmsgfont();
21023 }
21024 1201 }
21025 2693 }
21026
21027
2/2
✓ Branch 0 taken 23711 times.
✓ Branch 1 taken 4519 times.
187072 if(MsgStrings[msgstr].s.size() > unsigned(msgptr+1)
21028
2/2
✓ Branch 0 taken 158321 times.
✓ Branch 1 taken 521 times.
158842 && (MsgStrings[msgstr].s[msgptr]==' ')
21029
2/2
✓ Branch 0 taken 28230 times.
✓ Branch 1 taken 130091 times.
158321 && (MsgStrings[msgstr].s[msgptr+1]==' '))
21030 {
21031
2/2
✓ Branch 0 taken 4513 times.
✓ Branch 1 taken 156761 times.
161274 while(MsgStrings[msgstr].s[msgptr]==' ')
21032 {
21033 156761 msgspace = true;
21034 156761 tlength = msgfont->vtable->char_length(msgfont, MsgStrings[msgstr].s[msgptr]) + MsgStrings[msgstr].hspace;
21035
21036
2/2
✓ Branch 0 taken 464 times.
✓ Branch 1 taken 6280 times.
163505 if(cursor_x+tlength > (msg_w-msg_margins[right])
21037
4/6
✓ Branch 0 taken 6744 times.
✓ Branch 1 taken 150017 times.
✓ Branch 2 taken 6744 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 6280 times.
✗ Branch 5 not taken.
156761 && ((cursor_x > (msg_w-msg_margins[right]) || !(MsgStrings[msgstr].stringflags & STRINGFLAG_WRAP))
21038 464 ? true : strcmp(s3," ")!=0))
21039 {
21040 6744 ssc_tile_hei = ssc_tile_hei_buf;
21041
1/2
✓ Branch 0 taken 6744 times.
✗ Branch 1 not taken.
6744 int32_t thei = zc_max(ssc_tile_hei, text_height(msgfont));
21042 6744 ssc_tile_hei_buf = -1;
21043 6744 cursor_y += thei + MsgStrings[msgstr].vspace;
21044
2/2
✓ Branch 0 taken 6738 times.
✓ Branch 1 taken 6 times.
6744 if(bottom_margin_clip()) break;
21045 6738 cursor_x=msg_margins[left];
21046 6738 }
21047
21048 156755 cursor_x+=tlength;
21049 156755 ++msgpos;
21050 156755 ++msgptr;
21051
21052
2/2
✓ Branch 0 taken 10215 times.
✓ Branch 1 taken 146540 times.
156755 if(atend(MsgStrings[msgstr].s.c_str()+msgptr))
21053 {
21054
2/2
✓ Branch 0 taken 87448 times.
✓ Branch 1 taken 59092 times.
146540 if(MsgStrings[msgstr].nextstring)
21055 {
21056
1/2
✓ Branch 0 taken 59092 times.
✗ Branch 1 not taken.
59092 if(MsgStrings[MsgStrings[msgstr].nextstring].stringflags & STRINGFLAG_CONT)
21057 {
21058 msgstr=MsgStrings[msgstr].nextstring;
21059 msgpos=msgptr=0;
21060 msgfont=setmsgfont();
21061 }
21062 59092 }
21063 146540 }
21064 }
21065 4519 }
21066 }
21067 159829 }
21068 strendcheck:
21069 // Done printing the string
21070
14/14
✓ Branch 0 taken 166408 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 166384 times.
✓ Branch 3 taken 24 times.
✓ Branch 4 taken 165421 times.
✓ Branch 5 taken 963 times.
✓ Branch 6 taken 164189 times.
✓ Branch 7 taken 1232 times.
✓ Branch 8 taken 161624 times.
✓ Branch 9 taken 2565 times.
✓ Branch 10 taken 161618 times.
✓ Branch 11 taken 6 times.
✓ Branch 12 taken 159216 times.
✓ Branch 13 taken 6205 times.
166409 if(do_end_str || !doing_name_insert && !do_run_menu && (msgpos>=10000 || msgptr>=MsgStrings[msgstr].s.size() || bottom_margin_clip() || atend(MsgStrings[msgstr].s.c_str()+msgptr)) && !linkedmsgclk)
21071 {
21072
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 6205 times.
6206 if(!do_end_str)
21073
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6205 times.
6205 while(parsemsgcode()); // Finish remaining control codes
21074
21075 // Go to next string, or make it disappear by going to string 0.
21076
5/6
✓ Branch 0 taken 4219 times.
✓ Branch 1 taken 1987 times.
✓ Branch 2 taken 3275 times.
✓ Branch 3 taken 944 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 3275 times.
6206 if(MsgStrings[msgstr].nextstring!=0 || get_qr(qr_MSGDISAPPEAR) || enqueued_str)
21077 {
21078 2931 linkedmsgclk=do_end_str?1:51;
21079 2931 }
21080
21081
2/2
✓ Branch 0 taken 4219 times.
✓ Branch 1 taken 1987 times.
6206 if(MsgStrings[msgstr].nextstring==0)
21082 {
21083
2/2
✓ Branch 0 taken 944 times.
✓ Branch 1 taken 3275 times.
4219 if(!get_qr(qr_MSGDISAPPEAR))
21084 3275 {
21085 disappear:
21086 4218 msg_active = false;
21087 4218 Hero.finishedmsg();
21088 4218 }
21089
21090
2/2
✓ Branch 0 taken 5149 times.
✓ Branch 1 taken 13 times.
5162 if(repaircharge)
21091 {
21092 // if (get_qr(qr_REPAIRFIX)) {
21093 // fixed_door=true;
21094 // }
21095 13 game->change_drupy(-tmpscr[currscr<128?0:1].catchall);
21096 13 repaircharge = 0;
21097 13 }
21098
21099
2/2
✓ Branch 0 taken 5160 times.
✓ Branch 1 taken 2 times.
5162 if(adjustmagic)
21100 {
21101
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(get_qr(qr_OLD_HALF_MAGIC))
21102 {
21103
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if(game->get_magicdrainrate())
21104 2 game->set_magicdrainrate(1);
21105 2 }
21106 else if(game->get_magicdrainrate() > 1)
21107 {
21108 game->set_magicdrainrate(game->get_magicdrainrate()/2);
21109 }
21110 2 adjustmagic = false;
21111 2 sfx(WAV_SCALE);
21112
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 1 times.
2 setmapflag((currscr < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM);
21113 2 }
21114
21115
2/2
✓ Branch 0 taken 5160 times.
✓ Branch 1 taken 2 times.
5162 if(learnslash)
21116 {
21117 2 game->set_canslash(1);
21118 2 learnslash = false;
21119 2 sfx(WAV_SCALE);
21120
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 setmapflag((currscr < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM);
21121 2 }
21122 5162 }
21123 7149 }
21124 14448102 }
21125
21126 124237 int32_t message_more_y()
21127 {
21128 //Is the flag ticked, do we really want a message more y larger than 160?
21129
5/6
✓ Branch 0 taken 28 times.
✓ Branch 1 taken 124209 times.
✓ Branch 2 taken 124237 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 124209 times.
✓ Branch 5 taken 28 times.
124237 int32_t msgy=zc_min((zinit.msg_more_is_offset==0)?zinit.msg_more_y:zinit.msg_more_y+MsgStrings[msgstr].y ,160);
21130 124237 msgy+=playing_field_offset;
21131 124237 return msgy;
21132 }
21133
21134 /*** Collision detection & handling ***/
21135
21136 14149692 void clear_script_one_frame_conditions()
21137 {
21138
2/2
✓ Branch 0 taken 38761943 times.
✓ Branch 1 taken 14149692 times.
52911635 for(int32_t j=0; j<guys.Count(); j++)
21139 {
21140 38761943 enemy *e = (enemy*)guys.spr(j);
21141
2/2
✓ Branch 0 taken 658953031 times.
✓ Branch 1 taken 38761943 times.
697714974 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) e->hitby[q] = 0;
21142 38761943 }
21143 14149692 }
21144
21145 4851677 void check_enemy_lweapon_collision(weapon *w)
21146 {
21147
8/8
✓ Branch 0 taken 4239600 times.
✓ Branch 1 taken 612077 times.
✓ Branch 2 taken 3250638 times.
✓ Branch 3 taken 988962 times.
✓ Branch 4 taken 3188554 times.
✓ Branch 5 taken 62084 times.
✓ Branch 6 taken 16738 times.
✓ Branch 7 taken 3171816 times.
4851677 if(!(w->Dead()) && w->id!=wSword && w->id!=wHammer && w->id!=wWand)
21148 {
21149
2/2
✓ Branch 0 taken 3156245 times.
✓ Branch 1 taken 11156524 times.
14312769 for(int32_t j=0; j<guys.Count(); j++)
21150 {
21151 11156524 enemy *e = (enemy*)guys.spr(j);
21152
21153 11156524 bool didhit = e->hit(w);
21154
2/2
✓ Branch 0 taken 10936092 times.
✓ Branch 1 taken 220432 times.
11156524 if(didhit) //boomerangs and such that last for more than a frame can write hitby[] for more than one frame,
21155 //because this only checks `if(dying || clk<0 || hclk>0 || superman)`
21156 {
21157 // !(e->stunclk)
21158 220432 int32_t h = e->takehit(w);
21159
2/2
✓ Branch 0 taken 187002 times.
✓ Branch 1 taken 33430 times.
220432 if (h == -1)
21160 {
21161 33430 int indx = Lwpns.find(w);
21162
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 33430 times.
33430 if(indx > -1)
21163 33430 e->hitby[HIT_BY_LWEAPON] = indx+1;
21164 33430 e->hitby[HIT_BY_LWEAPON_UID] = w->script_UID;
21165 33430 e->hitby[HIT_BY_LWEAPON_TYPE] = w->id;
21166
2/2
✓ Branch 0 taken 31260 times.
✓ Branch 1 taken 2170 times.
33430 if (w->parentitem > -1) e->hitby[HIT_BY_LWEAPON_PARENT_FAMILY] = itemsbuf[w->parentitem].family;
21167 2170 else e->hitby[HIT_BY_LWEAPON_PARENT_FAMILY] = -1;
21168 33430 e->hitby[HIT_BY_LWEAPON_PARENT_ID] = w->parentitem;
21169 33430 e->hitby[HIT_BY_LWEAPON_ENGINE_UID] = w->getUID();
21170
21171 33430 }
21172 //we may need to handle this in special cases. -Z
21173
21174 //if h == stun or ignore
21175
21176 //if e->stun > DEFAULT_STUN -1 || !e->stun
21177 //if the enemy wasn't stunned this round -- what a bitch, as the stun value is set before we check this
21178 ///! how about: if w->dead != bounce !
21179
21180 // NOT FOR PUBLIC RELEASE
21181 /*if(h==3) //Mirror shield
21182 {
21183 if (w->id==ewFireball || w->id==wRefFireball)
21184 {
21185 w->id=wRefFireball;
21186 switch(e->dir)
21187 {
21188 case up: e->angle += (PI - e->angle) * 2.0; break;
21189 case down: e->angle = -e->angle; break;
21190 case left: e->angle += ((-PI/2) - e->angle) * 2.0; break;
21191 case right: e->angle += (( PI/2) - e->angle) * 2.0; break;
21192 // TODO: the following. -L.
21193 case l_up: break;
21194 case r_up: break;
21195 case l_down: break;
21196 case r_down: break;
21197 }
21198 }
21199 else
21200 {
21201 w->id = ((w->id==ewMagic || w->id==wRefMagic || w->id==wMagic) ? wRefMagic : wRefBeam);
21202 w->dir ^= 1;
21203 if(w->dir&2)
21204 w->flip ^= 1;
21205 else
21206 w->flip ^= 2;
21207 }
21208 w->ignoreHero=false;
21209 }
21210 else*/
21211
2/2
✓ Branch 0 taken 176399 times.
✓ Branch 1 taken 44033 times.
220432 if(h)
21212 {
21213
3/4
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 44029 times.
✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
44033 if(e->switch_hooked && w->family_class == itype_switchhook)
21214 w->onhit(false, e, -1);
21215 44033 else w->onhit(false, e, h);
21216 44033 }
21217
21218
2/2
✓ Branch 0 taken 217758 times.
✓ Branch 1 taken 2674 times.
220432 if(h==2)
21219 {
21220 2674 break;
21221 }
21222 217758 }
21223
21224
2/2
✓ Branch 0 taken 11140953 times.
✓ Branch 1 taken 12897 times.
11153850 if(w->Dead())
21225 {
21226 12897 break;
21227 }
21228 11140953 }
21229
21230 // Item flags added in 2.55:
21231 // BRang/HShot/Arrows item_flag4 is "Pick up anything" (port of qr_BRANGPICKUP)
21232 // BRang/HShot item_flag5 is "Drags Items" (port of qr_Z3BRANG_HSHOT)
21233 // Arrows item_flag2 is "Picks up items" (inverse port of qr_Z3BRANG_HSHOT)
21234 // -Em
21235
6/6
✓ Branch 0 taken 2717833 times.
✓ Branch 1 taken 453983 times.
✓ Branch 2 taken 2673261 times.
✓ Branch 3 taken 44572 times.
✓ Branch 4 taken 43559 times.
✓ Branch 5 taken 2629702 times.
3171816 if(w->id == wBrang || w->id == wHookshot || w->id == wArrow)
21236 {
21237 542114 int32_t itype, pitem = w->parentitem;
21238
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 453983 times.
✓ Branch 2 taken 43559 times.
✓ Branch 3 taken 44572 times.
542114 switch(w->id)
21239 {
21240 453983 case wBrang: itype = itype_brang; break;
21241 43559 case wArrow: itype = itype_arrow; break;
21242 case wHookshot:
21243 44572 itype = (w->family_class == itype_switchhook ? itype_switchhook :itype_hookshot);
21244 44572 break;
21245 }
21246
2/2
✓ Branch 0 taken 537262 times.
✓ Branch 1 taken 4852 times.
542114 if(pitem < 0) pitem = current_item_id(itype);
21247
5/6
✓ Branch 0 taken 44572 times.
✓ Branch 1 taken 497542 times.
✓ Branch 2 taken 100 times.
✓ Branch 3 taken 44472 times.
✓ Branch 4 taken 100 times.
✗ Branch 5 not taken.
542114 if(w->id == wHookshot && w->family_class == itype_switchhook && (itemsbuf[pitem].flags & item_flag9))
21248 { //Swap with item
21249 for(int32_t j=0; j<items.Count(); j++)
21250 {
21251 if(items.spr(j)->hit(w))
21252 {
21253 item *theItem = ((item*)items.spr(j));
21254 bool priced = theItem->PriceIndex >-1;
21255 bool isKey = itemsbuf[theItem->id].family==itype_key||itemsbuf[theItem->id].family==itype_lkey;
21256 if(!theItem->fallclk && !theItem->drownclk && ((theItem->pickup & ipTIMER && theItem->clk2 >= 32)
21257 || (((itemsbuf[w->parentitem].flags & item_flag4)||(theItem->pickup & ipCANGRAB)||((itemsbuf[w->parentitem].flags & item_flag7)&&isKey)) && !priced && !(theItem->pickup & ipDUMMY))))
21258 {
21259 if(!Hero.switchhookclk)
21260 {
21261 hooked_combopos = -1;
21262 hooked_layerbits = 0;
21263 switching_object = theItem;
21264 theItem->switch_hooked = true;
21265 w->misc = 2;
21266 w->step = 0;
21267 theItem->clk2=256;
21268 Hero.doSwitchHook(game->get_switchhookstyle());
21269 if(QMisc.miscsfx[sfxSWITCHED])
21270 sfx(QMisc.miscsfx[sfxSWITCHED],int32_t(w->x));
21271 }
21272 }
21273 }
21274 }
21275 }
21276
6/6
✓ Branch 0 taken 43559 times.
✓ Branch 1 taken 498555 times.
✓ Branch 2 taken 374095 times.
✓ Branch 3 taken 330536 times.
✓ Branch 4 taken 498555 times.
✓ Branch 5 taken 330536 times.
542114 else if((w->id==wArrow&&itemsbuf[pitem].flags & item_flag2)||(w->id!=wArrow&&!(itemsbuf[pitem].flags & item_flag5)))//An arrow with "Picks up items" or a BRang/HShot without "Drags items"
21277 {
21278
2/2
✓ Branch 0 taken 87310 times.
✓ Branch 1 taken 374095 times.
461405 for(int32_t j=0; j<items.Count(); j++)
21279 {
21280
2/2
✓ Branch 0 taken 82412 times.
✓ Branch 1 taken 4898 times.
87310 if(items.spr(j)->hit(w))
21281 {
21282 4898 item *theItem = ((item*)items.spr(j));
21283 4898 bool priced = theItem->PriceIndex >-1;
21284
2/2
✓ Branch 0 taken 132 times.
✓ Branch 1 taken 4766 times.
4898 bool isKey = itemsbuf[theItem->id].family==itype_key||itemsbuf[theItem->id].family==itype_lkey;
21285
5/8
✓ Branch 0 taken 4898 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4898 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3789 times.
✓ Branch 5 taken 1109 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 2065 times.
6963 if(!theItem->fallclk && !theItem->drownclk && ((theItem->pickup & ipTIMER && theItem->clk2 >= 32)
21286
4/6
✓ Branch 0 taken 3174 times.
✓ Branch 1 taken 2065 times.
✓ Branch 2 taken 3174 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 3174 times.
4898 || (((itemsbuf[pitem].flags & item_flag4)||(theItem->pickup & ipCANGRAB)||((itemsbuf[pitem].flags & item_flag7)&&isKey))&& !priced)))
21287 {
21288
1/2
✓ Branch 0 taken 1724 times.
✗ Branch 1 not taken.
5854 if(itemsbuf[theItem->id].collect_script)
21289 {
21290 ZScriptVersion::RunScript(ScriptType::Item, itemsbuf[theItem->id].collect_script, theItem->id & 0xFFF);
21291 }
21292
21293 1724 Hero.checkitems(j);
21294 1724 }
21295 4898 }
21296 87310 }
21297 374095 }
21298
2/2
✓ Branch 0 taken 14738 times.
✓ Branch 1 taken 153281 times.
829091 else if(w->id!=wArrow) //A BRang/HShot with "Drags Items"
21299 {
21300
2/2
✓ Branch 0 taken 36900 times.
✓ Branch 1 taken 153281 times.
190181 for(int32_t j=0; j<items.Count(); j++)
21301 {
21302
2/2
✓ Branch 0 taken 28212 times.
✓ Branch 1 taken 8688 times.
36900 if(items.spr(j)->hit(w))
21303 {
21304 8688 item *theItem = ((item*)items.spr(j));
21305 8688 bool priced = theItem->PriceIndex >-1;
21306
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 8681 times.
8688 bool isKey = itemsbuf[theItem->id].family==itype_key||itemsbuf[theItem->id].family==itype_lkey;
21307
4/6
✓ Branch 0 taken 8688 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8688 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 8454 times.
✓ Branch 5 taken 234 times.
8688 if(!theItem->fallclk && !theItem->drownclk && ((theItem->pickup & ipTIMER && theItem->clk2 >= 32)
21308
5/10
✓ Branch 0 taken 7273 times.
✓ Branch 1 taken 1181 times.
✓ Branch 2 taken 1415 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1415 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 1415 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
8688 || (((itemsbuf[pitem].flags & item_flag4)||(theItem->pickup & ipCANGRAB)||((itemsbuf[pitem].flags & item_flag7)&&isKey)) && !priced && !(theItem->pickup & ipDUMMY))))
21309 {
21310 7273 int32_t pickup = theItem->pickup;
21311 7273 int32_t id2 = theItem->id;
21312 7273 int32_t pstr = theItem->pstring;
21313 7273 int32_t pstr_flags = theItem->pickup_string_flags;
21314
21315 7273 std::vector<int32_t> &ev = FFCore.eventData;
21316 7273 ev.clear();
21317 7273 ev.push_back(id2*10000);
21318 7273 ev.push_back(pickup*10000);
21319 7273 ev.push_back(pstr*10000);
21320 7273 ev.push_back(pstr_flags*10000);
21321 7273 ev.push_back(0);
21322 7273 ev.push_back(theItem->getUID());
21323 7273 ev.push_back(GENEVT_ICTYPE_RANGED_DRAG*10000);
21324 7273 ev.push_back(w->getUID());
21325
21326 7273 throwGenScriptEvent(GENSCR_EVENT_COLLECT_ITEM);
21327 7273 bool nullify = ev[4] != 0;
21328
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7273 times.
7273 if(nullify) continue;
21329
2/2
✓ Branch 0 taken 1076 times.
✓ Branch 1 taken 6197 times.
7273 if(w->id == wBrang)
21330 {
21331 6197 w->onhit(false);
21332 6197 }
21333
21334
2/2
✓ Branch 0 taken 6775 times.
✓ Branch 1 taken 498 times.
7273 if(w->dragging==-1)
21335 {
21336 498 w->dead=1;
21337 498 theItem->clk2=256;
21338 498 w->dragging=j;
21339 498 theItem->is_dragged = true;
21340 498 }
21341 7273 }
21342 8688 }
21343 36900 }
21344 153281 }
21345 542114 }
21346 3171816 }
21347 4851677 }
21348 14147536 void check_collisions()
21349 {
21350
2/2
✓ Branch 0 taken 4851642 times.
✓ Branch 1 taken 14147536 times.
18999178 for(uint q = 0; q < Lwpns.Count(); ++q)
21351 4851642 check_enemy_lweapon_collision((weapon*)Lwpns.spr(q));
21352 14147536 }
21353
21354 14149692 void dragging_item()
21355 {
21356
2/2
✓ Branch 0 taken 4966950 times.
✓ Branch 1 taken 14149692 times.
19116642 for(int32_t i=0; i<Lwpns.Count(); i++)
21357 {
21358 4966950 weapon *w = (weapon*)Lwpns.spr(i);
21359
21360
4/4
✓ Branch 0 taken 4504375 times.
✓ Branch 1 taken 462575 times.
✓ Branch 2 taken 4811691 times.
✓ Branch 3 taken 155259 times.
4966950 if((w->id == wBrang || w->id==wHookshot)&&itemsbuf[w->parentitem].flags & item_flag5)//item_flag5 is a port for qr_Z3BRANG_HSHOT
21361 {
21362
3/4
✓ Branch 0 taken 7247 times.
✓ Branch 1 taken 148012 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7247 times.
155259 if(w->dragging>=0 && w->dragging<items.Count())
21363 {
21364 7247 item* dragItem = (item*)items.spr(w->dragging);
21365 7247 dragItem->x=w->x;
21366 7247 dragItem->y=w->y;
21367
21368 // Drag the Fairy enemy as well as the Fairy item
21369 7247 int32_t id = dragItem->id;
21370
21371
4/4
✓ Branch 0 taken 419 times.
✓ Branch 1 taken 6828 times.
✓ Branch 2 taken 404 times.
✓ Branch 3 taken 15 times.
7247 if(itemsbuf[id].family ==itype_fairy && itemsbuf[id].misc3)
21372 {
21373 404 movefairynew2(w->x,w->y,*dragItem);
21374 404 }
21375 7247 }
21376 155259 }
21377 4966950 }
21378 14149692 }
21379
21380 55 int32_t more_carried_items()
21381 {
21382 55 int32_t hasmorecarries = 0;
21383
21384
2/2
✓ Branch 0 taken 60 times.
✓ Branch 1 taken 55 times.
115 for(int32_t i=0; i<items.Count(); i++)
21385 {
21386
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 55 times.
60 if(((item*)items.spr(i))->pickup & ipENEMY)
21387 {
21388 55 hasmorecarries++;
21389 55 }
21390 60 }
21391
21392 55 return hasmorecarries;
21393 }
21394
21395 // messy code to do the enemy-carrying-the-item thing
21396 14149692 void roaming_item()
21397 {
21398
4/4
✓ Branch 0 taken 28207 times.
✓ Branch 1 taken 14121485 times.
✓ Branch 2 taken 70 times.
✓ Branch 3 taken 28137 times.
14149692 if(!(hasitem&(4|2)) || !loaded_enemies)
21399 14121555 return;
21400
21401 // All enemies already dead upon entering a room?
21402
1/2
✓ Branch 0 taken 28137 times.
✗ Branch 1 not taken.
28137 if(guys.Count()==0)
21403 {
21404 return;
21405 }
21406
21407 // Lost track of the carrier?
21408
5/6
✓ Branch 0 taken 28137 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 28131 times.
✓ Branch 3 taken 6 times.
✓ Branch 4 taken 28115 times.
✓ Branch 5 taken 16 times.
28137 if(guycarryingitem<0 || guycarryingitem>=guys.Count() ||
21409 28131 !((enemy*)guys.spr(guycarryingitem))->itemguy)
21410 {
21411 22 guycarryingitem=-1;
21412
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 84 times.
84 for(int32_t j=0; j<guys.Count(); j++)
21413 {
21414
2/2
✓ Branch 0 taken 62 times.
✓ Branch 1 taken 22 times.
84 if(((enemy*)guys.spr(j))->itemguy)
21415 {
21416 22 guycarryingitem=j;
21417 22 break;
21418 }
21419 62 }
21420 22 }
21421
21422
2/2
✓ Branch 0 taken 28073 times.
✓ Branch 1 taken 64 times.
28137 if(hasitem&4)
21423 {
21424 64 guycarryingitem = -1;
21425
21426
2/2
✓ Branch 0 taken 413 times.
✓ Branch 1 taken 64 times.
477 for(int32_t i=0; i<guys.Count(); i++)
21427 {
21428
2/2
✓ Branch 0 taken 349 times.
✓ Branch 1 taken 64 times.
413 if(((enemy*)guys.spr(i))->itemguy)
21429 {
21430 64 guycarryingitem = i;
21431 64 }
21432 413 }
21433
21434
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(guycarryingitem == -1) //This happens when "default enemies" such as
21435 {
21436 return; //eSHOOTFBALL are alive but enemies from the list
21437 } //are not. Defer to HeroClass::checkspecial().
21438
21439 64 int32_t Item=tmpscr->item;
21440
21441 64 hasitem &= ~4;
21442
21443
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 64 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 64 times.
64 if((!getmapflag(mITEM) || (tmpscr->flags9&fITEMRETURN)) && (tmpscr->hasitem != 0))
21444 {
21445 115 additem(0,0,Item,ipENEMY+ipONETIME+ipBIGRANGE
21446
2/2
✓ Branch 0 taken 51 times.
✓ Branch 1 taken 13 times.
64 + (((tmpscr->flags3&fHOLDITEM) || (itemsbuf[Item].family==itype_triforcepiece)) ? ipHOLDUP : 0)
21447 );
21448 64 hasitem |= 2;
21449 64 }
21450 else
21451 {
21452 return;
21453 }
21454 64 }
21455
21456
2/2
✓ Branch 0 taken 29483 times.
✓ Branch 1 taken 28137 times.
57620 for(int32_t i=0; i<items.Count(); i++)
21457 {
21458
2/2
✓ Branch 0 taken 1346 times.
✓ Branch 1 taken 28137 times.
29483 if(((item*)items.spr(i))->pickup&ipENEMY)
21459 {
21460
2/2
✓ Branch 0 taken 14272 times.
✓ Branch 1 taken 13865 times.
28137 if(get_qr(qr_HIDECARRIEDITEMS))
21461 {
21462 14272 items.spr(i)->x = -128; // Awfully inelegant, innit?
21463 14272 items.spr(i)->y = -128;
21464 14272 }
21465
2/4
✓ Branch 0 taken 13865 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 13865 times.
13865 else if(guycarryingitem>=0 && guycarryingitem<guys.Count())
21466 {
21467
1/2
✓ Branch 0 taken 13865 times.
✗ Branch 1 not taken.
13865 if (!get_qr(qr_BROKEN_ITEM_CARRYING))
21468 {
21469 if (get_qr(qr_ENEMY_DROPS_USE_HITOFFSETS))
21470 {
21471 items.spr(i)->x = guys.spr(guycarryingitem)->x+guys.spr(guycarryingitem)->hxofs+(guys.spr(guycarryingitem)->hit_width/2)-8;
21472 items.spr(i)->y = guys.spr(guycarryingitem)->y+guys.spr(guycarryingitem)->hyofs+(guys.spr(guycarryingitem)->hit_height/2)-10;
21473 }
21474 else
21475 {
21476 if(guys.spr(guycarryingitem)->extend >= 3)
21477 {
21478 items.spr(i)->x = guys.spr(guycarryingitem)->x+(guys.spr(guycarryingitem)->txsz-1)*8;
21479 items.spr(i)->y = guys.spr(guycarryingitem)->y-2+(guys.spr(guycarryingitem)->tysz-1)*8;
21480 }
21481 else
21482 {
21483 items.spr(i)->x = guys.spr(guycarryingitem)->x;
21484 items.spr(i)->y = guys.spr(guycarryingitem)->y - 2;
21485 }
21486 }
21487 items.spr(i)->z = guys.spr(guycarryingitem)->z;
21488 items.spr(i)->fakez = guys.spr(guycarryingitem)->fakez;
21489 }
21490 else
21491 {
21492 13865 items.spr(i)->x = guys.spr(guycarryingitem)->x;
21493 13865 items.spr(i)->y = guys.spr(guycarryingitem)->y - 2;
21494 13865 items.spr(i)->fakez = guys.spr(guycarryingitem)->fakez;
21495 }
21496 13865 }
21497 28137 }
21498 29483 }
21499 14149692 }
21500
21501 bool enemy::IsBigAnim()
21502 {
21503 return (anim == a2FRMB || anim == a4FRM8EYEB || anim == a4FRM4EYEB
21504 || anim == a4FRM8DIRFB || anim == a4FRM4DIRB || anim == a4FRM4DIRFB
21505 || anim == a4FRM8DIRB);
21506 }
21507 2389386 int32_t enemy::getFlashingCSet()
21508 {
21509 //Special cset for the dying sprite
21510
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2389386 times.
2389386 if(dying)
21511 {
21512 if (!get_qr(qr_HARDCODED_ENEMY_ANIMS) || BSZ || fading == fade_blue_poof)
21513 return wpnsbuf[spr_death].csets & 15;
21514 else
21515 return (((clk2 + 5) >> 1) & 3) + 6;
21516 }
21517
21518 //Normal cset
21519
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2389386 times.
2389386 if (hclk <= 0)
21520 {
21521 //Special cset for the flashing animation
21522 if (flags & guy_flashing)
21523 return (frame & 3) + 6;
21524 return cs;
21525 }
21526
21527 //Hurt animations
21528
2/2
✓ Branch 0 taken 3888 times.
✓ Branch 1 taken 2385498 times.
2389386 if(family==eeGANON)
21529 3888 return (((hclk-1)>>1)&3)+6;
21530
4/4
✓ Branch 0 taken 2216661 times.
✓ Branch 1 taken 168837 times.
✓ Branch 2 taken 487138 times.
✓ Branch 3 taken 1729523 times.
2385498 else if(hclk<33 && !get_qr(qr_ENEMIESFLICKER))
21531 1729523 return (((hclk-1)>>1)&3)+6;
21532
21533 655975 return cs;
21534 2389386 }
21535
21536 81517382 bool enemy::is_hitflickerframe(bool olddrawing)
21537 {
21538
6/6
✓ Branch 0 taken 81488878 times.
✓ Branch 1 taken 28504 times.
✓ Branch 2 taken 3939716 times.
✓ Branch 3 taken 77549162 times.
✓ Branch 4 taken 3167025 times.
✓ Branch 5 taken 772691 times.
81517382 if (family == eeGANON || !hclk || !get_qr(qr_ENEMIESFLICKER))
21539 80744691 return false;
21540
21541
3/4
✓ Branch 0 taken 496051 times.
✓ Branch 1 taken 276640 times.
✓ Branch 2 taken 496051 times.
✗ Branch 3 not taken.
772691 if (!olddrawing && !getCanFlicker())
21542 return false;
21543
21544 772691 int32_t fr = game->get_spriteflickerspeed();
21545
1/2
✓ Branch 0 taken 772691 times.
✗ Branch 1 not taken.
772691 if (fr == 0)
21546 return true;
21547 772691 return frame % (fr * 2) < fr;
21548 81517382 }
21549
21550 const char *old_guy_string[OLDMAXGUYS] =
21551 {
21552 "(None)","Abei","Ama","Merchant","Moblin","Fire","Fairy","Goriya","Zelda","Abei 2","Empty","","","","","","","","","",
21553 // 020
21554 "Octorok (L1, Slow)","Octorok (L2, Slow)","Octorok (L1, Fast)","Octorok (L2, Fast)","Tektite (L1)",
21555 // 025
21556 "Tektite (L2)","Leever (L1)","Leever (L2)","Moblin (L1)","Moblin (L2)",
21557 // 030
21558 "Lynel (L1)","Lynel (L2)","Peahat (L1)","Zora","Rock",
21559 // 035
21560 "Ghini (L1, Normal)","Ghini (L1, Phantom)","Armos","Keese (CSet 7)","Keese (CSet 8)",
21561 // 040
21562 "Keese (CSet 9)","Stalfos (L1)","Gel (L1, Normal)","Zol (L1, Normal)","Rope (L1)",
21563 // 045
21564 "Goriya (L1)","Goriya (L2)","Trap (4-Way)","Wall Master","Darknut (L1)",
21565 // 050
21566 "Darknut (L2)","Bubble (Sword, Temporary Disabling)","Vire (Normal)","Like Like","Gibdo",
21567 // 055
21568 "Pols Voice (Arrow)","Wizzrobe (Teleporting)","Wizzrobe (Floating)","Aquamentus (Facing Left)","Moldorm",
21569 // 060
21570 "Dodongo","Manhandla (L1)","Gleeok (1 Head)","Gleeok (2 Heads)","Gleeok (3 Heads)",
21571 // 065
21572 "Gleeok (4 Heads)","Digdogger (1 Kid)","Digdogger (3 Kids)","Digdogger Kid (1)","Digdogger Kid (2)",
21573 // 070
21574 "Digdogger Kid (3)","Digdogger Kid (4)","Gohma (L1)","Gohma (L2)","Lanmola (L1)",
21575 // 075
21576 "Lanmola (L2)","Patra (L1, Big Circle)","Patra (L1, Oval)","Ganon","Stalfos (L2)",
21577 // 080
21578 "Rope (L2)","Bubble (Sword, Permanent Disabling)","Bubble (Sword, Re-enabling)","Shooter (Fireball)","Item Fairy ",
21579 // 085
21580 "Fire","Octorok (Magic)", "Darknut (Death Knight)", "Gel (L1, Tribble)", "Zol (L1, Tribble)",
21581 // 090
21582 "Keese (Tribble)", "Vire (Tribble)", "Darknut (Splitting)", "Aquamentus (Facing Right)", "Manhandla (L2)",
21583 // 095
21584 "Trap (Horizontal, Line of Sight)", "Trap (Vertical, Line of Sight)", "Trap (Horizontal, Constant)", "Trap (Vertical, Constant)", "Wizzrobe (Fire)",
21585 // 100
21586 "Wizzrobe (Wind)", "Ceiling Master ", "Floor Master ", "Patra (BS Zelda)", "Patra (L2)",
21587 // 105
21588 "Patra (L3)", "Bat", "Wizzrobe (Bat)", "Wizzrobe (Bat 2) ", "Gleeok (Fire, 1 Head)",
21589 // 110
21590 "Gleeok (Fire, 2 Heads)", "Gleeok (Fire, 3 Heads)","Gleeok (Fire, 4 Heads)", "Wizzrobe (Mirror)", "Dodongo (BS Zelda)",
21591 // 115
21592 "Dodongo (Fire) ","Trigger", "Bubble (Item, Temporary Disabling)", "Bubble (Item, Permanent Disabling)", "Bubble (Item, Re-enabling)",
21593 // 120
21594 "Stalfos (L3)", "Gohma (L3)", "Gohma (L4)", "NPC 1 (Standing) ", "NPC 2 (Standing) ",
21595 // 125
21596 "NPC 3 (Standing) ", "NPC 4 (Standing) ", "NPC 5 (Standing) ", "NPC 6 (Standing) ", "NPC 1 (Walking) ",
21597 // 130
21598 "NPC 2 (Walking) ", "NPC 3 (Walking) ", "NPC 4 (Walking) ", "NPC 5 (Walking) ", "NPC 6 (Walking) ",
21599 // 135
21600 "Boulder", "Goriya (L3)", "Leever (L3)", "Octorok (L3, Slow)", "Octorok (L3, Fast)",
21601 // 140
21602 "Octorok (L4, Slow)", "Octorok (L4, Fast)", "Trap (8-Way) ", "Trap (Diagonal) ", "Trap (/, Constant) ",
21603 // 145
21604 "Trap (/, Line of Sight) ", "Trap (\\, Constant) ", "Trap (\\, Line of Sight) ", "Trap (CW, Constant) ", "Trap (CW, Line of Sight) ",
21605 // 150
21606 "Trap (CCW, Constant) ", "Trap (CCW, Line of Sight) ", "Wizzrobe (Summoner)", "Wizzrobe (Ice) ", "Shooter (Magic)",
21607 // 155
21608 "Shooter (Rock)", "Shooter (Spear)", "Shooter (Sword)", "Shooter (Fire)", "Shooter (Fire 2)",
21609 // 160
21610 "Bombchu", "Gel (L2, Normal)", "Zol (L2, Normal)", "Gel (L2, Tribble)", "Zol (L2, Tribble)",
21611 // 165
21612 "Tektite (L3) ", "Spinning Tile (Combo)", "Spinning Tile (Enemy Sprite)", "Lynel (L3) ", "Peahat (L2) ",
21613 // 170
21614 "Pols Voice (Magic)", "Pols Voice (Whistle)", "Darknut (Mirror) ", "Ghini (L2, Fire) ", "Ghini (L2, Magic) ",
21615 // 175
21616 "Grappler Bug (HP) ", "Grappler Bug (MP) "
21617 };
21618